\fs84 \s11 \li0 \fi756 \fi0 \ri1008 \gray0\cf0\f1 \b0 \i \fs88 The GNU Source-Level Debugger\
\fs120 \
\fs88 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \i0 \fs28 This chapter describes how to debug a C program using the GNU debugger from the Free Software Foundation (the GNU debugger has been extended in NEXTSTEP to support the use of Objective C and Mach).\
\fs20 \
\fs28 This chapter provides an overview of the GDB debugger and how to use it. The chapter ends with a discussion of NEXTSTEP-specific extensions to GDB. These NEXTSTEP extensions provide full compatibility with standard GDB, while offering the following additional features useful for developing programs within the NEXTSTEP software environment:\
\fs28 This chapter is a modified version of documentation provided by the Free Software Foundation; see the section \'aaLegal Considerations\'ba at the end of the chapter for important related information.\
\fs20 \
\fs28 This chapter Copyright \f3 \'d3\f1 1988 by Free Software Foundation, Inc. and Copyright \f3 \'d3\f1 1990, 1991, 1992 by NeXT Computer, Inc.\
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 The purpose of a debugger such as GDB is to allow you to execute another program while examining what\'27s going on inside it. We call the other program \'aayour program\'ba or \'aathe program being debugged.\'ba\
\fs20 \
\fs28 GDB can do four kinds of things (plus other things in support of these):\
\fs20 \
\fs28 \s7 \li2494 \fi-378 \'b7 Start the program, specifying anything that might affect its behavior.\
\fs20 \
\fs28 \'b7 Make the program stop on specified conditions.\
\fs20 \
\fs28 \'b7 Examine what has happened\'d0when the program has stopped\'d0so you can see bugs happen.\
\fs20 \
\fs28 \'b7 Change things in the program, so you can correct the effects of one bug and go on to learn about another without having to recompile first.\
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 To debug a program effectively, you need to ask for debugging information when you compile it. This information in the object file describes the data type of each variable or function and the correspondence between source line numbers and addresses in the executable code.\
\fs20 \
\fs28 To request debugging information, specify the \b -g\b0 option when you run the compiler. We recommend that you always use \b -g\b0 when you compile a program. You may think the program is correct, but there\'27s no sense in pushing your luck.\
\fs20 \
\fs28 Unlike the UNIX C compiler, the GNU C compiler supports debugging with optimization (by using the \b -O\b0 compiler option). Although GDB provides the capability to debug programs compiled with optimization, the debugger may provide confusing or misleading information when debugging optimized programs. The intention is to provide some recourse in those situations where debugging optimized programs is necessary. However, debugging optimized programs should not be done routinely.\
\fs20 \
\fs28 With these warnings in mind, it can still be useful to debug optimized programs, provided that you\'27re aware of the limitations of the debugger in these circumstances. Most importantly, the debugger should be able to provide correct backtraces of your program\'27s function call stack. This is often all that is needed to find the problem. Printing the values of variables, however, may give incorrect results, since the debugger has insufficient information to be sure where a variable resides at any given time. Variables declared \b volatile\b0 will always have correct values, and global variables will almost always be correct; local variables, however, are likely to be incorrectly reported.\
\fs20 \
\fs28 Variables declared \b register\b0 are optimized by the compiler even when optimizing is not requested with the \b -O\b0 compiler option\'d0these may also give misleading results. To ensure a completely predictable debugging environment, it\'27s best to compile without the \b -O\b0 flag and with the compiler option \'aa\b -Dregister\b0 =\'ba. This option causes the C preprocessor to effectively delete all \b register\b0 declarations from your program for this compilation. (In fact, with the GNU C compiler, there\'27s no need to declare any variables to be \b register\b0 variables. When optimizing, the GNU C compiler may place any variable in a register whether it\'27s declared \b register\b0 or not. On the other hand, declaring variables to be \b register\b0 variables may make it more difficult to debug your program when not optimizing. Therefore, the use of the \b register\b0 declaration is discouraged.)\
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 On a NEXTSTEP computer, you\'27re likely to use GDB by running it within a shell window using a conventional command-line interface\'d0you enter commands at the GDB prompt, and debugger output appears on subsequent lines. (You can also run GDB as a subprocess in the GNU Emacs editor, as described later in this chapter.)\
\fs20 \
\fs28 To start GDB from within a shell window, enter the following command:\
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \i name\i0 is the name of your executable program, and \i core\i0 , if specified, is the name of the core dump file to be examined. See the rest of this section for information about optional command-line arguments and switches. Once started, GDB reads commands from the terminal until you quit by giving the \b quit\b0 command.\
\fs20 \
\fs28 A GDB command is a single line of input. There\'27s no limit to how long it can be. It starts with a command name, optionally followed by arguments (some commands don\'27t allow arguments).\
\fs20 \
\fs28 GDB command names may always be abbreviated if the abbreviation is unambiguous. Sometimes even ambiguous abbreviations are allowed. For example, \b s\b0 is equivalent to \b step\b0 even though there are other commands whose names start with \b s\b0 . Possible command abbreviations are stated in the documentation of the individual commands.\
\fs20 \
\fs28 A blank line as input to GDB means to repeat the previous command verbatim. Certain commands don\'27t allow themselves to be repeated this way; these are commands for which unintentional repetition might cause trouble and which you\'27re unlikely to want to repeat. Certain others (\b list\b0 and \b x\b0 ) act differently when repeated because that\'27s more useful.\
\fs20 \
\fs28 A line of input starting with \b #\b0 is a comment; it does nothing. This is useful mainly in command files (see the section \'aaCommand Files\'ba).\
\fs20 \
\fs28 GDB prompts for commands by displaying the \b (gdb)\b0 prompt. You can change the prompt with the \b set prompt\b0 command (this is most useful when debugging GDB itself):\
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 To exit GDB, use the \b quit\b0 command (abbreviated \b q\b0 ). Control-C won\'27t exit from GDB, but rather will terminate the action of any GDB command that is in progress and return to GDB command level. It\'27s safe to type Control-C at any time because GDB doesn\'27t allow it to take effect until it\'27s safe. If your program is running, typing Control-C will interrupt the program and return you to the GDB prompt.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 GDB needs to know the file name of the program to be debugged. To debug a core dump of a previous run, GDB must be told the file name of the core dump.\
\fs20 \
\fs28 The simplest way to specify the executable and core dump file names is with two command arguments given when you start GDB. The first argument is used as the file for execution and symbols, and the second argument (if any) is used as the core dump file name. Thus,\
\fs28 specifies \b progm\b0 as the executable program and \b core\b0 as a core dump file to examine. (You don\'27t need to have a core dump file if you plan to debug the program interactively.)\
\fs20 \
\fs28 If you need to specify more precisely the files to debugged, you can do so with the following command-line options:\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \b -s\b0 \i file\i0 Read symbol table from \i file\i0 .\
\fs20 \
\fs28 \b -e\b0 \i file\i0 Use \i file\i0 as the executable file to execute when appropriate, and for examining pure data in conjunction with a core dump.\
\fs20 \
\fs28 \b -se\b0 \i file\i0 Read symbol table from \i file\i0 and use it as the executable file.\
\fs20 \
\fs28 \b -c\b0 \i file\i0 Use \i file\i0 as a core dump file to examine.\
\fi0 Add \i directory\i0 to the path to search for source files.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 All the options and command line arguments given are processed in sequential order. The order makes a difference when the \b -x\b0 command is used.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 The following additional command-line options can be used to affect certain aspects of the behavior of GDB:\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \b -nx\b0 Don\'27t execute commands from the \b .gdbinit\b0 init files. Normally, the commands in these files are executed after all the command options and arguments have been processed. (See the section \'aaCommand Files\'ba for more information.)\
\fs20 \
\fs28 \b -q\b0 Quiet. Don\'27t print the usual introductory messages.\
\fs20 \
\fs28 \b -batch\b0 Run in batch mode. Exit with code 1 after processing all the command files specified with \b -x\b0 (and \b .gdbinit\b0 , if not inhibited). Exit also if, due to an error, GDB would otherwise attempt to read a command from the terminal.\
\fs20 \
\fs28 \b -fullname\b0 This option is used when Emacs runs GDB as a subprocess. It tells GDB to produce the full file name and line number each time a stack frame is displayed (which includes each time the program stops).\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 GDB provides a history buffer that stores previously executed commands. You can call any of these commands back to the command line for editing and reexecution. For example, by pressing the up-arrow key repeatedly, you can step back through each of the commands that were issued since the beginning of the session; the down-arrow key steps forward through the history buffer.\
\fs36 Expansion of Variable, Function, and Method Names\
\fs20 \
\fs36 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 GDB supports command-line expansion of variable, function and method names. Type Esc-Esc or Tab to expand the current word on the command line to a matching name. If there is more than one match, the unique part is expanded and a beep occurs. Type Esc-l to display all possible completions.\
\fs36 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 GDB supports the \b csh\b0 history substitution mechanism. For example, \b !foo\b0 retrieves the last command you typed that begins with \b foo\b0 . History substitution is supported across \b gdb\b0 sessions by writing the command history to a \b .gdb_history\b0 file in the current directory. Automatic creation of this history file can be disabled with the command:\
\fs20 \
\fs28 \pard \s12 \li2494 \fi0 \ri1008 \ql \f2 \fs24 set history save off\
\fs28 History substitution can be contolled with the \b set history\b0 \b filename\b0 , \b set history size\b0 , \b set history save\b0 , and \b set history expansion\b0 commands. Also see the section on history substitution in the \b csh\b0 (1) UNIX manual page for more information.\
\fs36 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 You can use standard Emacs editing commands to edit the contents of the command line. All the basic Emacs command sequences work, as well as the arrow keys. The left and right arrow keys move the cursor along the command line, and the up and down arrow keys take you backward and forward through the command history.\
\fs20 \
\fs28 The following list of Emacs commands shows the default key combination associated with each command and a description of what that command does. The name in parentheses can be used to associate a different key combination with the command, as described later in this section.\
\fs28 \s26 \f1 \b0 \fs28 Esc < Move to beginning of history file\
\fi0 Esc > Move to end of history file\
\fi0 Control-N Go to next history file entry\
\fi0 Control-P Go to previous history file entry \
\fs20 \
\fs28 \s28 \fi0 \f0 \b \fs28 \fs4 \
\fs28 Miscellaneous Commands\
\fs6 \
\fs28 \s26 \f1 \b0 \fs28 Control-C Interrupt a program started by the Workspace \
\fi0 Control-L Clear screen \
\fi0 Control-R Redisplay current command line\
\fi0 Control-Q Insert a literal character\
\fi0 Control-I Insert a Tab\
\fi0 Control-T Transpose characters\
\fi0 Control-U \i n\i0 Repeat following command \i n\i0 times\
\fi0 Control-Z Suspend debugger, return to shell\
\fi0 Control-@ Set mark \
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 Most of these commands are self-explanatory; the ones requiring more discussion are presented below.\
\fs20 \
\fs28 Both delete commands and kill commands erase characters from the command line. Text that\'27s erased by a kill key (Control-K or Control-W) is placed in the \'aakill buffer.\'ba If you want to restore this text, use the \'aayank\'ba command, Control-Y. The yank command inserts the restored text at the current insertion point. In contrast, text that\'27s erased by one of the delete commands (Control-D, Control-H, Esc d, and Esc h) isn\'27t placed in the kill buffer, so it can\'27t be restored by the yank command.\
\fs20 \
\fs28 To enter a character that would otherwise be interpreted as an editing command, you must precede it with Control-Q. For example, to enter Control-D and have it interpreted as a literal rather than as the command to delete the current character, type:\
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 Editing commands can be repeated by typing Control-U followed by a number and then the command to be repeated. For example, to delete the last 15 characters typed, enter:\
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 If you want to suspend the operation of GDB temporarily and return to the UNIX prompt, type Control-Z. To return to GDB, type \b %gdb\b0 (a variant of the shell \b fg\b0 command; for more information, see the UNIX manual page for \b csh\b0 (1)).\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 You can use GNU Emacs to run GDB, as well as to view (and edit) the source files for the program you\'27re debugging with GDB.\
\fs20 \
\fs28 To use the Emacs GDB interface, give the command \b Esc x gdb\b0 in Emacs. Specify the executable file you want to debug as an argument. This command starts a GDB process as a subprocess of Emacs, with input and output through a newly created Emacs buffer. You can run more than one GDB subprocess by giving the command \b Esc x gdb\b0 more than once.\
\fs20 \
\fs28 Running GDB as an Emacs subprocess is just like using GDB in a Shell or Terminal window, except for two things:\
\fs20 \
\fs28 \s7 \li2494 \fi-378 \'b7 All terminal input and output goes through the Emacs buffer. This applies both to GDB commands and their output, and to the input and output done by the program you\'27re debugging. You can copy the text of previous commands and use them again; you can even use parts of the output in this way (all the facilities of Emacs\'27s Shell mode are available for this purpose).\
\fs20 \
\fs28 \'b7 GDB displays source code through Emacs. Each time GDB displays a stack frame, Emacs automatically finds the source file for that frame and puts an arrow (\b =>\b0 ) at the left margin of the current line.\
\fs20 \
\fs28 \s4 \li2116 \fi0 Explicit GDB list or search commands still produce output as usual, but you\'27ll probably have no reason to use them.\
\fs20 \
\fs28 You can use these special Emacs commands in the GDB buffer:\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \b Esc s\b0 Execute to another source line, like the GDB \b step\b0 command.\
\fs20 \
\fs28 \b Esc n\b0 Execute to the next source line in this function, skipping all function calls, like the GDB \b next\b0 command.\
\fs20 \
\fs28 \b Esc i\b0 Execute one instruction, like the GDB \b stepi\b0 command.\
\fs20 \
\fs28 \b Esc u\b0 Move up one stack frame (and display that frame\'27s source file in Emacs), like the GDB \b up\b0 command.\
\fs20 \
\fs28 \b Esc d\b0 Move down one stack frame (and display that frame\'27s source file in Emacs), like the GDB \b down\b0 command. (You can\'27t use \b Esc d\b0 to delete words in the usual fashion in the GDB buffer.)\
\fs20 \
\fs28 \b Control-C Control-F\
\fi0 \b0 Execute until exit from the selected stack frame, like the GDB \b finish\b0 command.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 In any source file, the Emacs command Control-X space (\b gdb-break\b0 ) tells GDB to set a breakpoint at the source line the point is on.\
\fs20 \
\fs28 The source files displayed in Emacs are in ordinary Emacs buffers which are visiting the source files in the usual way. You can edit the files in these buffers if you wish; but keep in mind that GDB communicates with Emacs in terms of the line numbers as they were at compile time. If you add or delete lines from the text, the line numbers that GDB knows will no longer correspond properly to the code.\
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 At startup, GDB reads configuration information from startup files in the following order:\
\s24 \f0 \fs28 2. \fs28 \f1 \b ./.gdbinit\b0 (the current directory\'27s startup file)\
\s4 \li2116 \fi0 \fs20 \
\fs28 To make your own customizations to GDB, put GDB commands in your home directory\'27s \b .gdbinit\b0 startup file. To make further customizations required for any specific project, put commands in a \b .gdbinit\b0 startup file within that project\'27s directory.\
\fs20 \
\fs28 For more information about making customizations to GDB, see the section \'aaDefining and Executing Sequences of Commands\'ba later in this chapter.\
\fs52 GDB Commands for Specifying and Examining Files\
\fs28 \
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 Usually you specify the files for GDB to work with by giving arguments when you invoke GDB. But occasionally it\'27s necessary to change to a different file during a GDB session. Or you may run GDB and forget to specify the files you want to use. In these situations the GDB commands to specify new files are useful.\
\fi0 \i0 Load the symbols from \i file\i0 , assuming \i file\i0 has been dynamically loaded. The second argument provides the starting address of the file\'27s text.\
\fs20 \
\fs28 \fi-1512 \b core-file\b0 [\i file\i0 ] \
\fi0 Specify a core dump file to be used as the contents of memory. Note that the core dump contains only the writable parts of memory; the read-only parts must come from the executable file.\b core-file\b0 with no argument specifies that no core file is to be used.\
\fi0 \
\fi0 This command has been superseded by the \b target core\b0 and \b detach\b0 commands.\
\fs20 \
\fs28 \fi-1512 \b exec-file\b0 [ \i file\i0 ]\
\fi0 Use \i file\i0 as program for getting contents of pure memory. If \i file\i0 cannot be found as specified, your execution directory path is searched for a command of that name. No argument means have no executable file.\
\fs20 \
\fs28 \fi-1512 \b file\b0 [ \i file\i0 ] Use \i file\i0 as program to be debugged. It is read for its symbols, for getting the contents of pure memory, and it is the program executed when you use the \b run\b0 command. If \i file\i0 cannot be found as specified, your execution directory path ($PATH) is searched for a command of that name. No argument means to have no executable file and no symbols.\
\fs20 \
\fs28 \b info files\b0 Print the names of the executable and core dump files currently in use by GDB, and the file from which symbols were loaded.\
\fs20 \
\fs28 \b kill\b0 Cancel running the program under GDB. This could be used if you want to debug a core dump instead. GDB ignores any core dump file if it\'27s actually running the program, so the \b kill\b0 command is the only sure way to go back to using the core dump file.\
\fs20 \
\fs28 \b load\b0 \i file\i0 Dynamically load \i file\i0 into the running program, and record its symbols for access from GDB.\
\fs20 \
\fs28 \b load-file\b0 \i file\
\fi0 \i0 Dynamically load the specified file into the debugged program. Any symbols are also added to GDB, so you can communicate with the new object file through the use of functions and variables.\
\fs20 \
\fs28 \fi-1512 \b path\b0 \i path\
\fi0 \i0 Add one or more directory to the beginning of the search path for object files. \b $cwd\b0 in the path means the current working directory. This path is like the \b $PATH\b0 shell variable; it is a list of directories, separated by colons. These directories are searched to find fully linked executable files and separately compiled object files as needed.\
\fs20 \
\fs28 \fi-1512 \b symbol-file\b0 [\i file\i0 ] \
\fi0 Read symbol table information from file \i file\i0 . The environment variable PATH is searched when necessary. Usually you\'27ll use both the \b exec-file\b0 and \b symbol-file\b0 commands on the same file.\
\fi0 \b \
\fi0 symbol-file\b0 with no argument clears GDB\'27s symbol table.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 While file-specifying commands allow both absolute and relative file names as arguments, GDB always converts the file name to an absolute one and remembers it that way.\
\fs20 \
\fs28 The \b symbol-file\b0 command causes GDB to forget the contents of its convenience variables, the value history, and all breakpoints and auto-display expressions. This is because they may contain pointers to the internal data recording symbols and data types, which are part of the old symbol table data being discarded inside GDB.\
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 To start your program under GDB, use the \b run\b0 command. The program must already have been specified using the \b exec-file\b0 command or with an argument to the \b gdb\b0 command (see the section \'aaSpecifying Files to Debug\'ba); what \b run\b0 does is create an inferior process, load the program into it, and set it in motion.\
\fs20 \
\fs28 The execution of a program is affected by certain types of information it receives from its superior. GDB provides ways to specify these, which you must do before starting the program. (You can change them after starting the program, but such changes don\'27t affect the program unless you start it over again.) The types of information are:\
\fs20 \
\fs28 \pard \s27 \li6148 \fi-3654 \ri1008 \ql \tx6148 \tx10432 The arguments You specify the arguments to give the program by passing them as arguments to the \b run\b0 command. You can also use the \b args\b0 command.\
\fs20 \
\fs28 \pard \s27 \li6148 \fi-3654 \ri1008 \ql \tx6148 \tx10432 The environment The program normally inherits its environment from GDB, but you can use the GDB commands \b set environment\b0 and \b delete environment\b0 to change parts of the environment that will be given to the program.\
\fs20 \
\fs28 The working directory The program inherits its working directory from GDB. You can set GDB\'27s working directory with the \b cd\b0 command in GDB.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 After the \b run\b0 command, the debugger does nothing but wait for your program to stop. See the section \'aaStopping and Continuing\'ba for more information.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 You specify the arguments to give the program by passing them as arguments to the \b run\b0 command. They\'27re first passed to a shell, which expands wildcard characters and performs redirection of I/O, and then passed to the program.\
\fs20 \
\fs28 The \b run\b0 command with no arguments uses the same arguments used by the previous \b run\b0 .\
\fs20 \
\fs28 With the \b args\b0 command you can specify the arguments to be used the next time the program is run. If \b args\b0 has no arguments, it means to use no arguments the next time the program is run. If you\'27ve run your program with arguments and want to run it again with no arguments, this is the only way to do so.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 Your program\'27s environment consists of a set of environment variables and their values. Environment variables conventionally record such things as your user name, your home directory, your terminal type, and your search path for programs to run. Usually you set up environment variables with the shell and they\'27re inherited by all the other programs you run. When debugging, it can be useful to try running the program with different environments without having to start the debugger over again.\
\fi0 Set the environment variable \i varname\i0 to \i value\i0 (for your program only, not for GDB itself). \i value\i0 may be any string; any interpretation is supplied by your program itself.\
\fi0 Cancel the variable \i varname\i0 from the environment passed to your program (thereby making the variable not be defined at all, which is different from giving the variable an empty value). This doesn\'27t affect the program until the next \b run\b0 command.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 Each time you start your program with \b run\b0 , the program inherits its working directory from the current working directory of GDB. GDB\'27s working directory is initially whatever it inherited from its superior, but you can specify the working directory for GDB with the \b cd\b0 command.\
\fs20 \
\fs28 The GDB working directory also serves as a default for the commands that specify files for GDB to operate on. See the section \'aaSpecifying Files to Debug.\'ba\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \b cd\b0 \i dir\i0 Set the working directory for GDB and the program being debugged to \i dir\i0 . The change doesn\'27t take effect for the program being debugged unitl the next time it is started.\
\fs20 \
\fs28 \b pwd\b0 Print GDB\'27s working directory.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 By default, the program you run under GDB uses as its source of input and output the same terminal that GDB uses.\
\fs20 \
\fs28 You can redirect the program\'27s input and/or output using standard redirection commands with the \b run\b0 command. For example,\
\fs20 \
\fs28 \s12 \li2494 \fi-378 \fi0 \f2 \fs24 run > outfile\
\fs28 starts the program, diverting its output to the file \b outfile\b0 .\
\fs20 \
\fs28 Another way to specify what the program should use as its source of input and output is with the \b tty\b0 command. This command accepts a file name as its argument, and causes that file to be the default for future \b run\b0 commands. For example,\
\fs28 causes processes started with subsequent \b run\b0 commands to default to using the terminal \b /dev/ttyb\b0 as their source of input and output. An explicit redirection in \b run\b0 overrides the \b tty\b0 command.\
\fs20 \
\fs28 When you use the \b tty\b0 command or redirect input in the \b run\b0 command, the input for your program comes from the specified file, but the input for GDB still comes from your terminal. The program\'27s controlling terminal is your terminal, not the terminal that the program is reading from; so if you want to type Control-C to stop the program, you must type it on your (GDB\'27s) terminal. Control-C typed on the program\'27s terminal is available to the program as ordinary input.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 The NEXTSTEP operating system allows GDB to begin debugging an already running process that was started outside GDB. To do this you must use the \b attach\b0 command instead of the \b run\b0 command.\
\fs20 \
\fs28 The \b attach\b0 command requires one argument, which is the process ID of the process you want to debug.\
\fi0 Attach to a process or file outside of GDB. This command attaches to another target, of the same type as your last \b target\b0 command (\b info files\b0 will show your target stack). The command may take as argument a process id or a device file. (The usual way to find out the process ID of the process is with the \b ps\b0 utility.) For a process id, you must have permission to send the process a signal, and it must have the same effective uid as the debugger. When using \b attach\b0 , you should use the \b file\b0 command to specify the program running in the process, and to load its symbol table.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 The first thing GDB does after arranging to debug the process is to stop it. You can examine and modify an attached process with all the GDB commands that are ordinarily available when you start processes with \b run\b0 . You can insert breakpoints; you can step and continue; you can modify storage. If you would rather the process continue running, use the \b cont\b0 (continue) command after attaching.\
\fs20 \
\fs28 When you\'27re finished debugging the attached process, you can use the \b detach\b0 command to detach the debugger from the attached process and resume execution of the process (or you can use Control-C to interrupt the process). After you give the \b detach\b0 command, that process and GDB become completely independent, and you\'27re ready to \b attach\b0 another process or start one with \b run\b0 .\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \b detach\b0 Detach a process or file previously attached. If a process, it is no longer traced, and it continues its execution. If you were debugging a file, the file is closed and GDB no longer accesses it.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 If you exit GDB or use the \b run\b0 command while you have an attached process, you kill that process. You\'27ll be asked for confirmation if you try to do either of these things.\
\fs20 \
\fs28 The following commands are for connecting to a target machine or process.\
\fi0 Connect to a target machine or process. The first argument is the type or protocol of the target machine. Remaining arguments are interpreted by the target protocol. For more information on the arguments for a particular protocol, type \b help target\b0 followed by the protocol name.\
\fs20 \
\fs28 \fi-1512 \b target child\
\fi0 \b0 Unix child process (started by the \b run\b0 command).\
\fs20 \
\fs28 \fi-1512 \b target core\b0 \i file\
\fi0 \i0 Use a core file as a target. Specify the filename of the core file.\
\fs20 \
\fs28 \fi-1512 \b target exec\b0 \i file\
\fi0 \i0 Use an executable file as a target. Specify the filename of the executable file.\
\fs20 \
\fs28 \fi-1512 \b target remote\b0 \i device\
\fi0 \i0 Use a remote computer via a serial line, using a GDB-specific protocol. Specify the serial device it is connected to (for example, \b /dev/ttya\b0 ).\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 The following commands are for kernel debugging.\
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 When you run a program normally, it runs until exiting. The purpose of using a debugger is so that you can stop it before that point, or so that if the program runs into trouble you can find out why.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 A signal is an asynchronous event that can happen in a program. The operating system defines the possible kinds of signals, and gives each kind a name and a number. For example, SIGINT is the signal a program gets when you type Control-C; SIGSEGV is the signal a program gets from referencing a place in memory far away from all the areas in use; SIGALRM occurs when the alarm clock timer goes off (which happens only if the program has requested an alarm).\
\fs20 \
\fs28 Some signals, including SIGALRM, are a normal part of the functioning of the program. Others, such as SIGSEGV, indicate errors; these signals are fatal (that is, they kill the program immediately) if the program hasn\'27t specified in advance some other way to handle the signal. SIGINT doesn\'27t indicate an error in the program, but it\'27s normally fatal, so it can carry out the purpose of Control-C: to kill the program.\
\fs20 \
\fs28 GDB can detect any occurrence of a signal in the program running under GDB\'27s control. You can tell GDB in advance what to do for each kind of signal.\
\fs20 \
\fs28 Normally, GDB is set up to ignore non-erroneous signals like SIGALRM (so as not to interfere with their role in the functioning of the program) but to stop the program immediately whenever an error signal happens. You can change these settings with the \b handle\b0 command. You must specify which signal you\'27re talking about with its number.\
\fi0 Print a table of all the kinds of signals and how GDB has been told to handle each one. You can use this to see the signal numbers of all the defined types of signals. Specify a signal number in order to print information about that signal only.\
\fi0 Change the way GDB handles signal \i signalnum\i0 . The \i keywords\i0 say what change to make.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 To use the \b handle\b0 command you must know the code number of the signal you\'27re concerned with. To find the code number, type \b info signal\b0 ; this prints a table of signal names and numbers.\
\fs20 \
\fs28 The keywords allowed by the \b handle\b0 command can be abbreviated. Their full names are:\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \b stop\b0 GDB should stop the program when this signal happens. This implies the \b print\b0 keyword as well.\
\fs20 \
\fs28 \b print\b0 GDB should print a message when this signal happens.\
\fs20 \
\fs28 \b nostop\b0 GDB shouldn\'27t stop the program when this signal happens. It may still print a message telling you that the signal has come in.\
\fs20 \
\fs28 \b noprint\b0 GDB shouldn\'27t mention the occurrence of the signal at all. This implies the \b nostop\b0 keyword as well.\
\fs20 \
\fs28 \b pass\b0 GDB should allow the program to see this signal; the program will be able to handle the signal, or may be terminated if the signal is fatal and not handled.\
\fs20 \
\fs28 \b nopass\b0 GDB shouldn\'27t allow the program to see this signal.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 When a signal has been set to stop the program, the program can\'27t see the signal until you continue. It will see the signal then, if \b pass\b0 is in effect for the signal in question at that time. In other words, after GDB reports a signal, you can use the \b handle\b0 command with \b pass\b0 or \b nopass\b0 to control whether that signal will be seen by the program when you later continue it.\
\fs20 \
\fs28 You can also use the \b signal\b0 command to prevent the program from seeing a signal, to cause it to see a signal it normally wouldn\'27t see, or to give it any signal at any time. See the section \'aaContinuing\'ba below.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 A breakpoint can be used to make your program stop whenever a certain point in the program is reached. You set breakpoints explicitly with GDB commands, specifying the place where the program should stop by line number, function name, or exact address in the program. You can add various other conditions to control whether the program will stop.\
\fs20 \
\fs28 Each breakpoint is assigned a number when it\'27s created; these numbers are successive integers starting with 1. In many of the commands for controlling various features of breakpoints, you use the breakpoint number to say which breakpoint you want to change. Each breakpoint may be \'aaenabled\'ba or \'aadisabled;\'ba if disabled, it has no effect on the program until you enable it again.\
\fs20 \
\fs28 The \b info breakpoints\b0 command prints a list of all breakpoints set and not cleared, showing their numbers, their location in the program, and any special features in use for them. Disabled breakpoints are included in the list, but marked as disabled. \b info breakpoints\b0 with a breakpoint number as its argument lists only that breakpoint. The convenience variable \b $_\b0 and the default address for the \b x\b0 command are set to the address of the last breakpoint listed (see the section \'aaExamining Memory\'ba). The \b info breakpoints\b0 command can be abbreviated as \b info break\b0 .\
\fs20 \
\fs28 Breakpoints can\'27t be used in a program if any other process is running that program. Attempting to run or continue the program with a breakpoint in this case will cause GDB to stop it. When this happens, you have two ways to proceed:\
\fs20 \
\fs28 \s7 \li2494 \fi-378 \'b7 Remove or disable the breakpoints, then continue.\
\fs20 \
\fs28 \'b7 Suspend GDB, and copy the file containing the program to a new name. Resume GDB and use the \b exec-file\b0 command to specify that GDB should run the program under that name. Then start the program again.\
\fs36 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 Breakpoints are set with the \b break\b0 command (abbreviated \b b\b0 ). There are several ways to specify where the breakpoint should go:\
\fi0 Set a breakpoint at entry to \i function\i0 . You can also set a breakpoint at the entry to a method, as described in the section \'aaMethod Names in Commands.\'ba\
\fs20 \
\fs28 \fi-1512 \b break\b0 \i linenum\i0 \
\fi0 Set a breakpoint at \i linenum\i0 in the current source file (the last file whose source text was printed). This breakpoint will stop the program just before it executes any of the code from that line.\
\fi0 Set a breakpoint at entry to \i function\i0 found in \i file\i0 . Specifying a file name as well as a function name is superfluous except when multiple files contain identically named functions. This doesn\'27t work for Objective C methods; see the section \'aaMethod Names in Commands\'ba for information on setting breakpoints for methods.\
\fs20 \
\fs28 \fi-1512 \b break *\b0 \i address\i0 \
\fi0 Set a breakpoint at \i address\i0 . You can use this to set breakpoints in parts of the program that don\'27t have debugging information or source files.\
\fs20 \
\fs28 \fi-1512 \b break\b0 Set a breakpoint at the next instruction to be executed in the selected stack frame (see the section \'aaExamining the Stack\'ba). This is a pointless thing to do in the innermost stack frame because the program would stop immediately after being started, but it\'27s very useful with another stack frame, because it will cause the program to stop as soon as control returns to that frame.\
\fi0 Set a breakpoint with condition \i cond\i0 ; evaluate the expression \i cond\i0 each time the breakpoint is reached, and stop only if the value is nonzero. \i args\i0 stands for one of the possible arguments described above (or no argument) specifying where to break. See the section \'aaBreak Conditions\'ba for more information.\
\fs20 \
\fs28 \fi-1512 \b tbreak\b0 [\i args\i0 ] \
\fi0 Set a breakpoint enabled only for one stop. \i args\i0 are the same as in the \b break\b0 command, and the breakpoint is set in the same way, but the breakpoint is automatically \'aadisabled\'ba the first time it\'27s hit.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 GDB allows you to set any number of breakpoints at the same place in the program. This can be useful when the breakpoints are conditional (see the section \'aaBreak Conditions\'ba).\
\fs36 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 It\'27s often necessary to eliminate a breakpoint once it has done its job and you no longer want the program to stop there. This is called clearing (or deleting) the breakpoint. A breakpoint that has been cleared no longer exists in any sense.\
\fs20 \
\fs28 With the \b clear\b0 command you can clear breakpoints according to where they are in the program. With the \b delete\b0 command you can clear individual breakpoints by specifying their breakpoint numbers.\
\fs20 \
\fs28 It isn\'27t necessary to clear a breakpoint to proceed past it. GDB automatically ignores breakpoints in the first instruction to be executed when you continue execution at the same address where the program stopped.\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \b clear\b0 Clear any breakpoints at the next instruction to be executed in the selected stack frame (see the section \'aaSelecting a Frame\'ba). When the innermost frame is selected, this is a good way to clear a breakpoint that the program just stopped at.\
\fs36 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 Rather than clearing a breakpoint, you might prefer to disable it. This makes the breakpoint inoperative as if it had been cleared, but remembers the information about the breakpoint so that you can enable it again later.\
\fs20 \
\fs28 You enable and disable breakpoints with the \b enable\b0 and \b disable\b0 commands, specifying one or more breakpoint numbers as arguments. Use \b info breakpoints\b0 to print a list of breakpoints if you don\'27t know which breakpoint numbers to use.\
\fs20 \
\fs28 A breakpoint can have any of four states of enablement:\
\fs20 \
\fs28 \s7 \li2494 \fi-378 \'b7 Disabled. The breakpoint has no effect on the program.\
\fs20 \
\fs28 \'b7 Enabled. The breakpoint will stop the program. A breakpoint made with the \b break\b0 command starts out in this state.\
\fs20 \
\fs28 \'b7 Enabled once. The breakpoint will stop the program, but when it does so it will become disabled. A breakpoint made with the \b tbreak\b0 command starts out in this state.\
\fs20 \
\fs28 \'b7 Enabled for deletion. The breakpoint will stop the program, but immediately afterward it will be deleted permanently.\
\fs20 \
\fs28 \s4 \li2116 \fi0 You can change the state of enablement of a breakpoint with the following commands:\
\fi0 Enable the specified breakpoints. They become effective once again in stopping the program, until you specify otherwise.\
\fs20 \
\fs28 \fi-1512 \b enable once\b0 \i bnum \i0 ...\
\fi0 Enable the specified breakpoints temporarily. Each will remain enabled only until the next time it stops the program (unless you use one of these commands to specify a different state before that time comes). Also see the \b tbreak\b0 command, which sets a breakpoint and enables it once.\
\fi0 Enable the specified breakpoints to work once and then die. Each of the breakpoints will be deleted the next time it stops the program (unless you use one of these commands to specify a different state before that time comes).\
\fi0 Disable the specified breakpoints. A disabled breakpoint has no effect but isn\'27t forgotten. All options such as ignore counts, conditions, and commands are remembered in case the breakpoint is enabled again later. This command may be abbreviated \b disable\b0 .\
\fi0 Delete some breakpoints or auto-display expressions. Arguments are breakpoint numbers with spaces in between. To delete all breakpoints, give no argument. This command may be abbreviated \b delete\b0 .\
\fi0 Enable some expressions to be displayed when the program stops. Arguments are the code numbers of the expressions to resume displaying. No argument means enable all automatic-display expressions. Do \b info display\b0 to see the current list of code numbers.\
\fi0 Disable some expressions to be displayed when the program stops. Arguments are the code numbers of the expressions to stop displaying. No argument means disable all automatic-display expressions. Do \b info display\b0 to see the current list of code numbers.\
\fi0 Cancel some expressions to be displayed when the program stops. Arguments are the code numbers of the expressions to stop displaying. No argument means cancel all automatic-display expressions. Do \b info display\b0 to see the current list of code numbers.\
\fs20 \
\fs28 \fi-1512 \b catch\b0 [ \i arg\i0 ... ]\
\fi0 Set breakpoints to catch exceptions that are raised. Argument may be a single exception to catch, multiple exceptions to catch, or the default exception \b default\b0 . If no arguments are given, breakpoints are set at all exception handlers catch clauses within the current scope.\
\fs20 \
\fs28 \fi-1512 A condition specified for the catch applies to all breakpoints set with this command.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 Aside from the automatic disablement or deletion of a breakpoint when it stops the program, which happens only in certain states, the state of enablement of a breakpoint changes only when one of the above commands is used.\
\fs36 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 The simplest sort of breakpoint breaks every time the program reaches a specified place. You can also specify a condition for a breakpoint. A condition is simply a boolean expression. A breakpoint with a condition evaluates the expression each time the program reaches it, and the program stops only if the condition is true.\
\fs20 \
\fs28 Break conditions may have side effects, and may even call functions in your program. These may sound like strange things to do, but their effects are completely predictable unless there\'27s another enabled breakpoint at the same address. (In that case, GDB might see the other breakpoint first and stop the program without checking the condition of this one.) Note that breakpoint commands are usually more convenient and flexible than break conditions for the purpose of performing side effects when a breakpoint is reached (see the section \'aaExecuting Commands at a Breakpoint\'ba).\
\fs20 \
\fs28 Break conditions can be specified when a breakpoint is set, by using \b if\b0 in the arguments to the \b break\b0 command (see the section \'aaSetting Breakpoints\'ba). They can also be changed at any time with the \b condition\b0 command:\
\fi0 Specify \i expression\i0 as the break condition for breakpoint number \i bnum\i0 . From now on, this breakpoint will stop the program only if the value of \i expression\i0 is true (nonzero, in C). \i expression\i0 isn\'27t evaluated at the time the \b condition\b0 command is given.\
\fs20 \
\fs28 \fi-1512 \b condition\b0 \i bnum\i0 \
\fi0 Remove the condition from breakpoint number \i bnum\i0 . It becomes an ordinary unconditional breakpoint.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 A special feature is provided for one kind of condition: to prevent the breakpoint from doing anything until it has been reached a certain number of times. This is done with the \'aaignore count\'ba of the breakpoint. When the program reaches a breakpoint whose ignore count is positive, then instead of stopping, it just decrements the ignore count by 1 and continues.\
\fi0 Set the ignore count of breakpoint number \i bnum\i0 to \i count\i0 . The next \i count\i0 times the breakpoint is reached, it won\'27t stop.\
\fi0 \
\fi0 To make the breakpoint stop the next time it\'27s reached, specify a count of 0.\
\fs20 \
\fs28 \fi-1512 \b continue\b0 \i n\
\fi0 \i0 Continue execution of the program, setting the ignore count of the breakpoint that the program stopped at to \i n\i0 minus 1. Continuing through the breakpoint doesn\'27t itself count as one of \i n\i0 . Thus, the program won\'27t stop at this breakpoint until the \i n\i0 th time it\'27s hit.\
\fi0 \
\fi0 This command is allowed only when the program stopped due to a breakpoint. At other times, the argument to \b cont\b0 is ignored.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 If a breakpoint has a positive ignore count and a condition, the condition isn\'27t checked. Once the ignore count reaches 0, the condition will start to be checked.\
\fs20 \
\fs28 You could achieve the effect of the ignore count with a condition such as \b $foo--<= 0\b0 using a debugger convenience variable that\'27s decremented each time. That\'27s why the ignore count is considered a special case of a condition. See the section \'aaConvenience Variables.\'ba\
\fs36 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 You can give any breakpoint a series of commands to execute when the program stops due to that breakpoint. For example, you might want to print the values of certain expressions, or enable other breakpoints.\
\fi0 Specify commands for breakpoint number \i bnum\i0 . The commands themselves appear on the following lines. Type a line containing just \b end\b0 to terminate the commands.\
\fi0 \
\fi0 To remove all commands from a breakpoint, use the command \b commands\b0 and follow it immediately by \b end\b0 ; that is, give no commands.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 Breakpoint commands can be used to start up the program again. Simply use the \b continue\b0 command, or \b step\b0 , or any other command that resumes execution. However, any remaining breakpoint commands are ignored. When the program stops again, GDB will act according to why that stop took place.\
\fs20 \
\fs28 If the first command specified is \b silent\b0 , the usual message about stopping at a breakpoint isn\'27t printed. This may be desirable for breakpoints that are to print a specific message and then continue. If the remaining commands also print nothing, you\'27ll see no sign that the breakpoint was reached at all. \b silent\b0 isn\'27t really a command; it\'27s meaningful only at the beginning of the commands for a breakpoint.\
\fs20 \
\fs28 The commands \b echo\b0 and \b output\b0 , which allow you to print precisely controlled output, are often useful in silent breakpoints. See the section \'aaCommands for Controlled Output.\'ba\
\fs20 \
\fs28 Here\'27s how you could use breakpoint commands to print the value of \b x\b0 at entry to \b foo\b0 whenever it\'27s positive. We assume that the newly created breakpoint is number 4; \b break\b0 will print the number that\'27s assigned.\
\fs28 One application for breakpoint commands is to correct one bug so you can test another. Put a breakpoint just after the erroneous line of code, give it a condition to detect the case in which something erroneous has been done, and give it commands to assign correct values to any variables that need them. End with the \b cont\b0 command so that the program doesn\'27t stop, and start with the \b silent\b0 command so that no output is produced. Here\'27s an example:\
\fs28 One deficiency in the operation of breakpoints that continue automatically appears when your program uses raw mode for the terminal. GDB reverts to its own terminal modes (not raw) before executing commands, and then must switch back to raw mode when your program is continued. This causes any pending terminal input to be lost.\
\fs20 \
\fs28 You could get around this problem by putting the actions in the breakpoint condition instead of in commands. For example,\
\fs28 is a condition expression that will change \b x\b0 as needed, then always have the value 0 so the program won\'27t stop. Loss of input is avoided here because break conditions are evaluated without changing the terminal modes. When you want to have nontrivial conditions for performing the side effects, the operators \b &&\b0 , \b || \b0 , and \b ?:\b0 may be useful.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 After your program stops, most likely you\'27ll want it to run some more if the bug you\'27re looking for hasn\'27t happened yet. You can do this with the \b continue\b0 command:\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \b continue\b0 Continue running the program at the place where it stopped.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 If the program stopped at a breakpoint, the place to continue running is the address of the breakpoint. You might expect that continuing would just stop at the same breakpoint immediately. In fact, \b continue\b0 takes special care to prevent that from happening. You don\'27t need to clear the breakpoint to proceed through it after stopping at it.\
\fs20 \
\fs28 You can, however, specify an ignore count for the breakpoint that the program stopped at, by means of an argument to the \b continue\b0 command. See the section \'aaBreak Conditions\'ba above.\
\fs20 \
\fs28 If the program stopped because of a signal other than SIGINT or SIGTRAP, continuing will cause the program to see that signal. You may not want this to happen. For example, if the program stopped due to some sort of memory reference error, you might store correct values into the erroneous variables and continue, hoping to see more execution; but the program would probably terminate immediately as a result of the fatal signal once it sees the signal. To prevent this, you can continue with \b signal 0\b0 . You can also act in advance to prevent the program from seeing certain kinds of signals, using the \b handle\b0 command (see the section \'aaSignals\'ba).\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 Stepping means setting your program in motion for a limited time, so that control will return automatically to the debugger after one line of code or one machine instruction. Breakpoints are active during stepping and the program will stop for them even if it hasn\'27t gone as far as the stepping command specifies.\
\fi0 Proceed the program until control reaches a different line, then stop it and return to the debugger. If an argument is specified, proceed as in \b step\b0 , but do so \i count\i0 times. If a breakpoint or a signal not related to stepping is reached before \i count\i0 steps, stepping stops right away. You can abbreviate this command as \b s\b0 .\
\fs20 \
\fs28 \fi-1512 \b next\b0 [\i count\i0 ]\
\fi0 Similar to \b step\b0 , but any function calls appearing within the line of code are executed without stopping. Execution stops when control reaches a different line of code at the stack level which was executing when the \b next\b0 command was given. An argument is a repeat count, as in \b step\b0 . You can abbreviate this command as \b n\b0 .\
\fs20 \
\fs28 \fi-1512 \b finish\b0 Continue running until just after the selected stack frame returns (or until there\'27s some other reason to stop, such as a fatal signal or a breakpoint). Upon return, the value returned is printed and put in the value history. Contrast this with the \b return\b0 command, described in the section \'aaReturning from a Function.\'ba\
\fs20 \
\fs28 \b until \b0 \i linenum\
\fi0 \i0 Continue running until line number \i linenum\i0 is reached or the current stack frame returns. This is equivalent to setting a breakpoint at \i linenum\i0 , executing a \b finish\b0 command, and deleting the breakpoint.\
\fs20 \
\fs28 \fi-1512 \b stepi\b0 [\i count\i0 ]\
\fi0 Proceed one machine instruction, then stop and return to the debugger. It\'27s often useful to do \b display/i $pc\b0 when stepping by machine instructions. This will cause the next instruction to be executed to be displayed automatically at each stop (see the section \'aaAutomatic Display\'ba). An argument is a repeat count, as in \b step\b0 . You can abbreviate this command as \b si\b0 .\
\fs20 \
\fs28 \fi-1512 \b nexti\b0 [\i count\i0 ]\
\fi0 Proceed one machine instruction, but if it\'27s a subroutine call, proceed until the subroutine returns. An argument is a repeat count, as in \b next\b0 . You can abbreviate this command as \b ni\b0 .\
\fs20 \
\fs28 \fi-1512 \b watch\b0 \i exp\
\fi0 \i0 Single-step the program until \i exp\i0 is true. This method is slow, but accurate. For a similar method that\'27s faster but less accurate, see the section on data breakpoints.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 A typical technique for using stepping is to put a breakpoint at the beginning of the function or the section of the program in which a problem is believed to lie, and then step through the suspect area examining interesting variables until the problem happens.\
\fs20 \
\fs28 The \b cont\b0 command can be used after stepping to resume execution until the next breakpoint or signal.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 Data breakpoints are implemented using a scheme that involves calling a handler function at the end of every function. This allows the program to break at the end of the function that changed the data, thereby narrowing the search for the offending line to a space between the last function called within a function and the last line of that function. The offending line is somewhere before the stopping point\'d0specifically, somewhere between the end of the last function that was called and the end of this function.\
\fs20 \
\fs28 The following commands provide support for data breakpoints:\
\fi0 Causes the program to break at the end of the function that changes the specified data. The first form specifies that the data starts at \i address\i0 for \i size\i0 bytes. The second form specifies that the data starts at &\i expression\i0 and continue for the size of \i expression\i0 (an Objective C object is considered to be the size that its class dictates at the time of the \b data-break\b0 command). With no arguments, \b data-break\b0 removes any \b data-break\b0 condition currently in effect.\
\fi0 Causes \i function-name\i0 to be called every time a function is exited. The prototype of the function is int (handlerFunction)(void). If a non-zero value is returned, the program will break at the end of the last function that was called. With no arguments, this command removes the exit handler.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 There are two caveats. First, functions without frame pointers are exempt from checking. Second, the address being checked must be readable at all times that the data breakpoint handler will be called. Otherwise an exception will be generated inside the inferior program. \b gdb\b0 will catch this, and you\'27ll have to turn off checking by using the \b data-break\b0 command with no arguments. \
\fs20 \
\fs28 The following examples illustrate the use of the \b data-break\b0 command.\
\fs20 \
\fs28 \s7 \li2494 \fi-378 \'b7 The program will stop if anything in the range 0x1000 through 0x100b changes:\
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 When your program has stopped, the first thing you need to know is where it stopped and how it got there.\
\fs20 \
\fs28 Each time your program performs a function call, the information about where in the program the call was made from is saved in a block of data called a \i stack frame\i0 . The frame also contains the arguments of the call and the local variables of the function that was called. All the stack frames are allocated in a region of memory called the call stack. When your program stops, the GDB commands for examining the stack allow you to see all this information.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 The call stack is divided into contiguous pieces called frames; each frame is the data associated with one call to one function. The frame contains the arguments given to the function, the function\'27s local variables, and the address at which the function is executing.\
\fs20 \
\fs28 When your program is started, the stack has only one frame, that of the function \b main()\b0 . This is called the initial frame, or the outermost frame. Each time a function is called, a new frame is made. Each time a function returns, the frame for that function invocation is eliminated. If a function is recursive, there can be many frames for the same function. The frame for the function in which execution is actually occurring is called the innermost frame. This is the most recently created of all the stack frames that still exist.\
\fs20 \
\fs28 Inside your program, stack frames are identified by their addresses. A stack frame consists of many bytes, each of which has its own address; each kind of computer has a convention for choosing the address of one of those bytes to serve as the address of the frame. Usually this address is kept in a register called the frame pointer register while execution is going on in that frame.\
\fs20 \
\fs28 GDB assigns numbers to all existing stack frames, starting with 0 for the innermost frame, 1 for the frame that called it, and so on upward. These numbers don\'27t really exist in your program; they simply give you a way of talking about stack frames in GDB commands.\
\fs20 \
\fs28 At any given time, one of the stack frames is selected by GDB; many GDB commands refer implicitly to this selected frame. In particular, whenever you ask GDB for the value of a variable in the program, the value is found in the selected frame. You can select any frame using the \b frame\b0 , \b up\b0 , and \b down\b0 commands; subsequent commands will operate on that frame.\
\fs20 \
\fs28 When the program stops, GDB automatically selects the currently executing frame and describes it briefly, as the \b frame\b0 command does (see the section \'aaInformation about a Frame\'ba).\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 A backtrace is a summary of how the program got where it is. It shows one line per frame, for many frames, starting with the currently executing frame (frame 0) followed by its caller (frame 1), and on up the stack.\
\fs20 \
\fs28 Each line in a backtrace shows the frame number, the program counter, the function and its arguments, and the source file name and line number (if known). For example:\
\fi0 Print a backtrace of the entire stack: one line per frame for all frames in the stack. You can stop the backtrace at any time by typing the system interrupt character, normally Control-C. With a positive argument, the command prints the innermost \i n\i0 frames; with a negative argument, it prints the outermost \i n\i0 frames. You can abbreviate this command as \b bt\b0 . An alias for this command is \b where\b0 .\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 Most commands for examining the stack and other data in the program work on whichever stack frame is selected at the moment. Below are the commands for selecting a stack frame.\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \b frame\b0 \i n\i0 Select and print frame number \i n\i0 . Recall that frame 0 is the innermost (currently executing) frame, frame 1 is the frame that called the innermost one, and so on. The highest-numbered frame is \b main\b0 \'27s frame.\
\fs20 \
\fs28 \b frame\b0 \i addr\i0 \
\fi0 Select and print the frame at address \i addr\i0 . This is useful mainly if the chaining of stack frames has been damaged by a bug, making it impossible for GDB to assign numbers properly to all frames. In addition, this can be useful if the program has multiple stacks and switches between them.\
\fs20 \
\fs28 \fi-1512 \b up\b0 \i n\i0 Select and print the frame \i n\i0 frames up from the frame previously selected. For positive numbers \i n\i0 , this advances toward the outermost frame, to higher frame numbers, to frames that have existed longer. \i n\i0 defaults to 1.\
\fs20 \
\fs28 \b up-silently\b0 \i n\
\fi0 \i0 Same as the \b up\b0 command, but doesn\'27t print anything (this is useful in command scripts).\
\fs20 \
\fs28 \fi-1512 \b down\b0 \i n\i0 Select and print the frame \i n\i0 frames down from the frame previously selected. For positive numbers \i n\i0 , this advances toward the innermost frame, to lower frame numbers, to frames that were created more recently. \i n\i0 defaults to 1.\
\fs20 \
\fs28 \b down-silently\b0 \i n\
\fi0 \i0 Same as the \b down\b0 command, but doesn\'27t print anything (this is useful in command scripts).\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 All these commands (except \b up-silently\b0 and \b down-silently\b0 ) end by printing some information about the frame that has been selected: the frame number, the function name, the arguments, the source file and line number of execution in that frame, and the text of that source line. For example:\
\fs20 \
\fs28 \pard \s12 \li2494 \fi0 \ri1008 \ql \f2 \fs24 #3 main (argc=3, argv=??, env=??) at main.c, line 67 \
\fs28 After such a printout, the \b list\b0 command with no arguments will print ten lines centered on the point of execution in the frame. See the section \'aaPrinting Source Lines.\'ba\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 There are several other commands to print information about the selected stack frame.\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \b frame\b0 [\i n\i0 ] This command prints a brief description of the selected stack frame. With an argument, this command is used to select a stack frame (the argument can be a stack frame number or the address of a frame); with no argument, it doesn\'27t change which frame is selected, but still prints the same information. You can abbreviate this command as \b f\b0 .\
\fs20 \
\fs28 \b info frame\b0 \
\fi0 This command prints a verbose description of the selected stack frame, including the address of the frame, the addresses of the next frame down (called by this frame) and the next frame up (caller of this frame), the address of the frame\'27s arguments, the program counter saved in it (the address of execution in the caller frame), and which registers were saved in the frame. The verbose description is useful when something has gone wrong that has made the stack format fail to fit the usual conventions.\
\fs20 \
\fs28 \fi-1512 \b info frame\b0 \i addr\i0 \
\fi0 Print a verbose description of the frame at address \i addr\i0 , without selecting that frame. The selected frame remains unchanged by this command.\
\fs20 \
\fs28 \fi-1512 \b info args\b0 Print the arguments of the selected frame, each on a separate line.\
\fs20 \
\fs28 \b info locals\b0 Print the local variables of the selected frame, each on a separate line.\
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 GDB knows which source files your program was compiled from, and can print parts of their text. When your program stops, GDB spontaneously prints the line it stopped in. Likewise, when you select a stack frame (see the section \'aaSelecting a Frame\'ba), GDB prints the line in which execution in that frame has stopped. You can also print parts of source files by explicit command.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 To be able to dynamically open and view source files in Edit, use the \b view\b0 command. This command is executed automatically when you start GDB from the Project Builder application.\
\fi0 Cause source files to be viewed in Edit, either on the local machine or on a remote \i host\i0 . When you first execute this command, a Gdb command is added to Edit\'27s main menu. This command brings up a control panel that allows you to control some of GDB\'27s basic functions from within Edit (see Chapter 4 for details).\
\fs20 \
\fs28 \fi-1512 \b unview\b0 Cause source files not to be viewed in Edit.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 To print lines from a source file, use the \b list\b0 command (abbreviated \b l\b0 ). There are several ways to specify what part of the file you want to print.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 Here are the most commonly used forms of \b the list\b0 command:\
\fi0 Print ten lines centered around \i linenum\i0 in the current source file.\
\fs20 \
\fs28 \fi-1512 \b list\b0 \i function\i0 \
\fi0 Print ten lines centered around the beginning of \i function\i0 .\
\fs20 \
\fs28 \fi-1512 \b list\b0 Print ten more lines. If the last lines printed were printed with a \b list\b0 command, this prints ten lines following the last lines printed; however, if the last line printed was a solitary line printed as part of displaying a stack frame (see the section \'aaExamining the Stack\'ba), this prints ten lines centered around that line.\
\fs20 \
\fs28 \b list \f3 \b0 -\f1 Print ten lines just before the lines last printed.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 You can repeat a \b list\b0 command by pressing the Return key; however, any argument that was used is discarded, so this is equivalent to typing simply \b list\b0 . An exception is made for an argument of \b -\b0 ; that argument is preserved in repetition so that each repetition moves up in the file.\
\fs20 \
\fs28 In general, the \b list\b0 command expects you to supply zero, one, or two linespecs. Linespecs specify source lines; there are several ways of writing them but the effect is always to specify some source line. The possible arguments for \b list\b0 are as follows:\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \b list ,\b0 \i last\i0 Print ten lines ending with \i last\i0 .\
\fs20 \
\fs28 \b list\b0 \i first\b \i0 ,\b0 Print ten lines starting with \i first\i0 .\
\fs20 \
\fs28 \b list +\b0 Print ten lines just after the lines last printed.\
\fs20 \
\fs28 \b list \f3 \b0 -\f1 Print ten lines just before the lines last printed.\
\fs20 \
\fs28 \b list\b0 \i linespec\i0 \
\fi0 Print ten lines centered around the line specified by \i linespec\i0 (described below).\
\fi0 Print lines from \i first\i0 to \i last\i0 . Both arguments are \i linespec\i0 s.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 Here are the possible ways to specify a value for \i linespec\i0 :\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \i linenum\i0 Specifies line \i linenum\i0 of the current source file. When a \b list\b0 command has two \i linespec\i0 s, this refers to the same source file as the first \i linespec\i0 .\
\fs20 \
\fs28 \b +\b0 \i offset\i0 Specifies the line \i offset\i0 lines after the last line printed. When used as the second \i linespec\i0 in a \b list\b0 command, this specifies the line \i offset\i0 lines down from the first \i linespec\i0 .\
\fs20 \
\fs28 \f3 -\f1 \i offset\i0 Specifies the line \i offset\i0 lines before the last line printed.\
\fs20 \
\fs28 \i file\i0 :\i linenum\
\fi0 \i0 Specifies line \i linenum\i0 in the source file \i file\i0 .\
\fs20 \
\fs28 \fi-1512 \i function\i0 Specifies the line of the left brace (\{) that begins the body of \i function\i0 .\
\fs20 \
\fs28 \i file\i0 :\i function\i0 \
\fi0 Specifies the line of the left brace (\{) that begins the body of \i function\i0 in \i file\i0 . The file name is needed with a function name only for disambiguating identically named functions in different source files.\
\fs20 \
\fs28 \fi-1512 *\i addr\i0 Specifies the line containing the program address \i addr\i0 . \i addr\i0 may be any expression.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 The \b info line\b0 command is used to map source lines to program addresses:\
\fi0 Print the starting and ending addresses of the compiled code for source line \i line\i0 , which can be specified as:\
\fs20 \
\fs28 \fi-1512 \i linenum\i0 , to list around that line in current file,\
\fi0 \i file\i0 :\i linenum\i0 , to list around that line in that file,\
\fi0 \i function\i0 , to list around beginning of that function, or\
\fi0 \i file\i0 :\i function\i0 , to distinguish among like-named static functions.\
\fi0 \
\fi0 With no argument, the command describes the last source line that was listed.\
\fs20 \
\fs28 \fi-1512 The default address for the \b x\b0 command is changed to the starting address of the line, so that \b x/i\b0 is sufficient to begin examining the machine code (see the section \'aaExamining Memory\'ba). Also, this address is saved as the value of the convenience variable \b $_\b0 (see the section \'aaConvenience Variables\'ba).\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 The \b forward-search\b0 command (or its alias, \b search\b0 ) and the \b reverse-search\b0 command are useful when you want to locate text within the current source file.\
\fi0 This command checks each line, starting with the one following the last line listed, for a match for \i regexp\i0 , which must be a UNIX regular expression (see the UNIX manual page for \b ed\b0 ). It lists the line that\'27s found. You can abbreviate this command as \b fo\b0 .\
\fi0 The command checks each line, starting with the one before the last line listed and going backward, for a match for \i regexp\i0 . It lists the line that\'27s found. You can abbreviate this command as \b rev\b0 .\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 Executable programs don\'27t record the directories of the source files they were compiled from, just the names. GDB remembers a list of pathnames of directories in which it will search for source files; this list is called the source path (note that GDB doesn\'27t use the environment variable PATH to search for source files). Each time GDB wants a source file, it tries each directory in the list, starting from the beginning, until it finds a file with the desired name.\
\fs20 \
\fs28 When you start GDB, its source path is set to \b $cdir:$cwd\b0 (the current working directory, and the directory in which the source file was compiled into object code). To add other directories, use the \b directory\b0 command:\
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 The most common way to examine data in your program is with the \b print\b0 command (abbreviated \b p\b0 ):\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \b print\b0 \i exp\i0 This command evaluates and prints the value of any valid expression of the language the program is written in (currently, only C and Objective C). Variables accessible are those of the lexical environment of the selected stack frame, plus all those whose scope is global or an entire file.\
\fs20 \
\fs28 \i exp\i0 is any valid expression, and the value of \i exp\i0 is printed in a format appropriate to its data type. To print data in another format, you can cast \i exp\i0 to the desired type or use the \b x\b0 command.\
\fs20 \
\fs28 \b $\b0 \i num\i0 gets previous value number \i num\i0 . \b $\b0 and \b $$\b0 are the last two values. \b $$\b0 \i num\i0 refers to the \i num\i0 \'27th value back from the last one. Names starting with \b $\b0 refer to registers (with the values they would have if the program were to return to the stack frame now selected, restoring all registers saved by frames farther in) or else to debugger convenience variables (any such name that isn\'27t a known register). Use assignment expressions to give values to convenience variables.\
\fs20 \
\fs28 \b \{\b0 \i type\b \i0 \}\b0 \i adrexp\i0 refers to a datum of data type \i type\i0 , located at address \i adrexp\i0 . \b @\b0 is a binary operator for treating consecutive data objects anywhere in memory as an array. \i foo\b \i0 @\b0 \i num\i0 gives an array whose first element is \i foo\i0 , whose second element is stored in the space following where \i foo\i0 is stored, etc. \i foo\i0 must be an expression whose value resides in memory.\
\fs20 \
\fs28 \i exp\i0 may be preceded with \b /\b0 \i fmt\i0 , where \i fmt\i0 is a format letter but no count or size letter (see the description of the \b x\b0 command).\
\fs20 \
\fs28 \b print-object\b0 \i object\
\fi0 \i0 Print \i object\i0 by sending \b printForDebugger:\b0 to it.\
\fs20 \
\fs28 \fi-1512 \b set\b0 \i exp\i0 The \b set\b0 command works like the \b print\b0 command, except that the expression\'27s value isn\'27t displayed. This is useful for modifying the state of your program. For example:\
\fs28 Another way to examine data is with the \b x\b0 command (see \'aaExamining Memory\'ba below). It examines data in memory at a specified address and prints it in a specified format.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 Many different GDB commands accept an expression and compute its value. Any kind of constant, variable, or operator defined by the programming language you\'27re using is legal in an expression in GDB. This includes conditional expressions, function calls, casts, and string constants.\
\fs20 \
\fs28 GDB supports three kinds of operator in addition to those of programming languages:\
\fi0 \b ::\b0 allows you to specify a variable in terms of the file or function it\'27s defined in.\
\fs20 \
\fs28 \fi-1512 \b @\b0 \b @\b0 is a binary operator for treating parts of memory as arrays. See the section \'aaArtificial Arrays\'ba below for more information.\
\fs20 \
\fs28 \b \{\b0 \i type\b \i0 \}\b0 \i addr\i0 \
\fi0 Refers to an object of type \i type\i0 stored at address \i addr\i0 in memory. \i addr\i0 may be any expression whose value is an integer or pointer (but parentheses are required around nonunary operators, just as in a cast). This construct is allowed no matter what kind of data is officially supposed to reside at \i addr\i0 .\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 The most common kind of expression to use is the name of a variable in your program.\
\fs20 \
\fs28 Variables in expressions are understood in the selected stack frame (see the section \'aaSelecting a Frame\'ba); they must be either global (or static) or visible according to the scope rules of the programming language from the point of execution in that frame. This means that in the function\
\fs28 the variable \b a\b0 is usable whenever the program is executing within the function \b foo()\b0 , but the variable \b b\b0 is usable only while the program is executing inside the block in which \b b\b0 is declared.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 It\'27s often useful to print out several successive objects of the same type in memory (for example, a section of an array, or an array of dynamically determined size for which only a pointer exists in the program).\
\fs20 \
\fs28 This can be done by constructing an \'aaartificial array\'ba with the binary operator \b @\b0 . The left operand of \b @\b0 should be the first element of the desired array, as an individual object. The right operand should be the length of the array. The result is an array value whose elements are all of the type of the left argument. The first element is actually the left argument; the second element comes from bytes of memory immediately following those that hold the first element, and so on. For example, if a program says\
\fs28 The left operand of \b @\b0 must reside in memory. Array values made with \b @\b0 in this way behave just like other arrays in terms of subscripting, and are coerced to pointers when used in expressions.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 GDB normally prints all values according to their data types. Sometimes this isn\'27t what you want. For example, you might want to print a number in hexadecimal, or a pointer in decimal. Or you might want to view data in memory at a certain address as a character string or an instruction. These things can be done with output formats.\
\fs20 \
\fs28 The simplest use of output formats is to specify how to print a value already computed. This is done by starting the arguments of the \b print\b0 command with a slash and a format letter. The format letters supported are:\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \b x\b0 Regard the bits of the value as an integer, and print the integer in hexadecimal.\
\fs20 \
\fs28 \b d\b0 Print as integer in signed decimal.\
\fs20 \
\fs28 \b u\b0 Print as integer in unsigned decimal.\
\fs20 \
\fs28 \b o\b0 Print as integer in octal.\
\fs20 \
\fs28 \b a\b0 Print as an address, both absolute in hexadecimal and then relative to a symbol defined at an address below it.\
\fs20 \
\fs28 \b c\b0 Regard as an integer and print as a character constant.\
\fs20 \
\fs28 \b f\b0 Regard the bits of the value as a floating-point number and print using typical floating-point syntax.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 For example, to print the program counter in hexadecimal (see the section \'aaRegisters\'ba), type\
\fs28 No space is required before the slash because command names in GDB can\'27t contain a slash.\
\fs20 \
\fs28 To reprint the last value in the value history with a different format, you can use the \b print\b0 command with just a format and no expression. For example, \b p/x\b0 reprints the last value in hexadecimal.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 The command \b x\b0 (for \'aaexamine\'ba) can be used to examine memory under explicit control of formats, without reference to the program\'27s data types.\
\fs20 \
\fs28 \b x\b0 is followed by a slash and an output format specification, followed by an expression for an address:\
\fs20 \
\fs28 x/\i fmt\i0 \i addr\
\fs20 \
\fs28 \i0 The expression \i addr\i0 doesn\'27t need to have a pointer value (though it may); it\'27s used as an integer, as the address of a byte of memory.\
\fs20 \
\fs28 The output format \i fmt\i0 in this case specifies both how big a unit of memory to examine and how to print the contents of that unit. It\'27s done with one or two of the letters listed below.\
\fs20 \
\fs28 These letters specify the size of unit to examine:\
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 These letters specify how to print the contents:\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \b x\b0 Print as integers in unsigned hexadecimal.\
\fs20 \
\fs28 \b d\b0 Print as integers in signed decimal.\
\fs20 \
\fs28 \b u\b0 Print as integers in unsigned decimal.\
\fs20 \
\fs28 \b o\b0 Print as integers in unsigned octal.\
\fs20 \
\fs28 \b a\b0 Print as an address, both absolute in hexadecimal and then relative to a symbol defined as an address below it.\
\fs20 \
\fs28 \b c\b0 Print as character constants (this implies size \b b\b0 ).\
\fs20 \
\fs28 \b f\b0 Print as floating point. This works only with sizes \b w\b0 and \b g\b0 .\
\fs20 \
\fs28 \b s\b0 Print a null-terminated string of characters. The specified unit size is ignored; instead, the unit is however many bytes it takes to reach a null character (including the null character).\
\fs20 \
\fs28 \b i\b0 Print a machine instruction in assembler syntax (or nearly). The specified unit size is ignored; the number of bytes in an instruction varies depending on the type of machine, the opcode and the addressing modes used.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 If neither the manner of printing nor the size of unit is specified, the default is the same as was used last. If you don\'27t want to use any letters after the slash, you can omit the slash as well.\
\fs20 \
\fs28 You can also omit the address to examine. Then the address used is just after the last unit examined. This is why string and instruction formats actually compute a unit-size based on the data: so that the next string or instruction examined will start in the right place. The \b print\b0 command sometimes sets the default address for the \b x\b0 command; when the value printed resides in memory, the default is set to examine the same location. \b info line\b0 also sets the default for \b x\b0 , to the address of the start of the machine code for the specified line and \b info breakpoints\b0 sets it to the address of the last breakpoint listed.\
\fs20 \
\fs28 When you repeat an \b x\b0 command by pressing the Return key, the address specified previously (if any) is ignored; instead, the command examines successive locations in memory rather than the same one.\
\fs20 \
\fs28 You can examine several consecutive units of memory with one command by writing a repeat count after the slash (before the format letters, if any). The repeat count must be a decimal integer. It has the same effect as repeating the \b x\b0 command that many times except that the output may be more compact with several units per line.\
\fs28 Prints ten instructions starting with the one to be executed next in the selected frame. After doing this, you could print another ten following instructions with\
\fs28 in which the format and address are allowed to default.\
\fs20 \
\fs28 The addresses and contents printed by the \b x\b0 command aren\'27t put in the value history because there\'27s often too much of them and they would get in the way. Instead, GDB makes these values available for subsequent use in expressions as values of the convenience variables \b $_\b0 and \b $__\b0 (that is, \b $\b0 followed by one or two underscores).\
\fs20 \
\fs28 After an \b x\b0 command, the last address examined is available for use in expressions in the convenience variable \b $_\b0 . The contents of that address, as examined, are available in the convenience variable \b $__\b0 .\
\fs20 \
\fs28 If the \b x\b0 command has a repeat count, the address and contents saved are from the last memory unit printed; this isn\'27t the same as the last address printed if several units were printed on the last line of output.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 If you find that you want to print the value of an expression frequently (to see how it changes), you might want to add it to the \'aaautomatic display list\'ba so that GDB will print its value each time the program stops. Each expression added to the list is given a number to identify it; to remove an expression from the list, you specify that number. The automatic display looks like this:\
\fi0 Add the expression \i exp\i0 to the list of expressions to display each time the program stops.\
\fs20 \
\fs28 \fi-1512 \b display/\b0 \i fmt exp\i0 \
\fi0 Add the expression \i exp\i0 to the automatic display list, and display it in the format \i fmt\i0 . \i fmt\i0 should specify only a display format, not a size or count.\
\fs20 \
\fs28 \fi-1512 \b display/\b0 \i fmt addr\i0 \
\fi0 Add the expression \i addr\i0 as a memory address to be examined each time the program stops. \i fmt\i0 should be either \b i\b0 or \b s\b0 , or it should include a unit size or a number of units. See the section \'aaExamining Memory.\'ba\
\fs20 \
\fs28 \fi-1512 \b undisplay\b0 [ \i n\i0 ... ]\
\fi0 Remove item number \i n\i0 from the list of expressions to display. With no argument, cancels all automatic-display expressions.\
\fs20 \
\fs28 \fi-1512 \b display\b0 Display the current values of the expressions on the list, just as is done when the program stops.\
\fs20 \
\fs28 \b info display\b0 \
\fi0 Print the list of expressions to display automatically, each one with its item number, but without showing the values.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 Every value printed by the \b print\b0 command is saved for the entire session in GDB\'27s \'aavalue history\'ba so that you can refer to it in other expressions.\
\fs20 \
\fs28 The values printed are given \'aahistory numbers\'ba for you to refer to them by. These are successive integers starting with 1. \b print\b0 shows you the history number assigned to a value by printing \b $\b0 \i n\b \i0 = \b0 before the value, where \i n\i0 is the history number.\
\fs20 \
\fs28 To refer to any previous value, use \b $\b0 followed by the value\'27s history number. The output printed by \b print\b0 is designed to remind you of this. \b $\b0 alone refers to the most recent value in the history, and \b $$\b0 refers to the value before that.\
\fs20 \
\fs28 For example, suppose you have just printed a pointer to a structure and want to see the contents of the structure. It\'27s enough to type\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 GDB provides \'aaconvenience variables\'ba that you can use within GDB to hold a value for future reference. These variables exist entirely within GDB; they aren\'27t part of your program, and setting a convenience variable has no effect on further execution of your program. That\'27s why you can use them freely.\
\fs20 \
\fs28 Convenience variables have names starting with \b $\b0 . Any name starting with \b $\b0 can be used for a convenience variable, unless it\'27s one of the predefined set of register names (see the section \'aaRegisters\'ba).\
\fs20 \
\fs28 You can save a value in a convenience variable with an assignment expression, just as you would set a variable in your program. For example:\
\fs28 would save in \b $foo\b0 the value contained in the object pointed to by \b object_ptr\b0 .\
\fs20 \
\fs28 Convenience variables don\'27t need to be explicitly declared; using a convenience variable for the first time creates it. However, its value is \b void\b0 until you assign it a value. You can alter the value with another assignment at any time.\
\fs20 \
\fs28 Convenience variables have no fixed types. You can assign a convenience variable any type of value, even if it already has a value of a different type. The convenience variable as an expression has whatever type its current value has.\
\fs20 \
\fs28 One way to use a convenience variable is as a counter to be incremented or a pointer to be advanced. For example:\
\fs28 Some convenience variables are created automatically by GDB and given values likely to be useful.\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \b $_\b0 The variable \b $_\b0 (single underscore) is automatically set by the \b x\b0 command to the last address examined (see the section \'aaExamining Memory\'ba). Other commands which provide a default address for \b x\b0 to examine also set \b $_\b0 to that address; these commands include \b info line\b0 and \b info breakpoint\b0 .\
\fs20 \
\fs28 \b $__\b0 The variable \b $__\b0 (two underscores) is automatically set by the \b x\b0 command to the value found in the last address examined.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 Machine register contents can be referred to in expressions as variables with names starting with \b $\b0 .\
\fs20 \
\fs28 The names \b $pc\b0 and \b $sp\b0 are used for the program counter register and the stack pointer. \b $fp\b0 is used for a register that contains a pointer to the current stack frame. To see a list of all the registers, use the command \b info registers\b0 .\
\fs20 \
\fs28 Some registers have distinct \'aaraw\'ba and \'aavirtual\'ba data formats. This means that the data format in which the register contents are saved by the operating system isn\'27t the same one that your program normally sees. For example, the registers of the 68882 floating-point coprocessor are always saved in \'aaextended\'ba format, but all C programs expect to work with \'aadouble\'ba format. In such cases, GDB normally works with the virtual format only (the format that makes sense for your program), but the \b info registers\b0 command prints the data in both formats.\
\fs20 \
\fs28 Register values are relative to the selected stack frame (see the section \'aaSelecting a Frame\'ba). This means that you get the value that the register would contain if all stack frames farther in were exited and their saved registers restored. In order to see the real contents of all registers, you must select the innermost frame (with \b frame 0\b0 ).\
\fs20 \
\fs28 Some registers are never saved (typically those numbered 0 or 1) because they\'27re used for returning function values; for these registers, relativization makes no difference.\
\fi0 With no argument, print the names and relativized values of all registers. With an argument, print the relativized value of register \i regname\i0 . \i regname\i0 may be any register name valid on the machine you\'27re using, with or without the initial \b $\b0 .\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 For example, you could print the program counter in hexadecimal with\
\fs28 The last is a way of removing one word from the stack. This assumes that the innermost stack frame is selected. Setting \b $sp\b0 isn\'27t allowed when other stack frames are selected.\
\fs48 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \f1 \b0 \fs28 \b call\b0 \i arg\i0 Call a function in the inferior process. The argument is the function name and arguments, in standard C notation. The result is printed and saved in the value history, if it isn\'27t void.\
\fi0 Disassemble a specified section of memory. The default is the function surrounding the \b pc\b0 of the selected frame. With a single argument, the function surrounding that address is dumped. Two arguments are taken as a range of memory to dump.\
\fs20 \
\fs28 \fi-1512 \b whereis\b0 \i variable\
\fi0 \i0 Print the location of the specified variable.\
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 The commands described in this section allow you to make inquiries for information about the symbols (names of variables, functions, and types) defined in your program. GDB finds this information in the symbol table contained in the executable file; it\'27s inherent in the text of your program and doesn\'27t change as the program executes.\
\fi0 With no argument, print the data type of \b $\b0 , the last value in the value history. With an argument, print the data type of expression \i exp\i0 . \i exp\i0 isn\'27t actually evaluated, and any operations inside it that have side effects (such as assignments or function calls) don\'27t take place.\
\fs20 \
\fs28 \fi-1512 \b info address\b0 \i symbol\i0 \
\fi0 Describe where the data for \i symbol\i0 is stored. For register variables, this says which register. For other automatic variables, this prints the stack-frame offset at which the variable is always stored. Note the contrast with \b print &\b0 \i symbol\i0 , which doesn\'27t work at all for register variables, and which for automatic variables prints the exact address of the current instantiation of the variable.\
\fs20 \
\fs28 \fi-1512 \b info functions\b0 [\i regexp\i0 ] \
\fi0 With no argument, print the names and data types of all defined functions. With an argument, print the names and data types of all defined functions whose names contain a match for regular expression \i regexp\i0 (for information about regular expressions, see the UNIX manual page for \b ed\b0 ). For example, \b info fun step\b0 finds all functions whose names include \b step\b0 ; \b info fun ^step\b0 finds those whose names start with \b step\b0 .\
\fs20 \
\fs28 \fi-1512 \b info sources\b0 \
\fi0 Print the names of all source files in the program for which there is debugging information.\
\fs20 \
\fs28 \fi-1512 \b info types\b0 [\i regexp\i0 ] \
\fi0 With no argument, print all data types that are defined in the program. With an argument, print all data types that are defined in the program whose names contain a match for regular expression \i regexp\i0 .\
\fs20 \
\fs28 \fi-1512 \b info variables\b0 [\i regexp\i0 ] \
\fi0 With no argument, print the names and data types of all top-level variables that are declared outside functions. With an argument, print the names and data types of all variables declared outside functions, whose names contain a match for regular expression \i regexp\i0 .\
\fs20 \
\fs28 \fi-1512 \b printsyms\b0 \i file\i0 \
\fi0 Write a complete dump of the debugger\'27s symbol data into the file \i file\i0 .\
\fs20 \
\fs28 \fi-1512 \b ptype\b0 \i typename\i0 \
\fi0 Print a description of data type \i typename\i0 . \i typename\i0 may be the name of a type, or for C code it may have the form \b struct\b0 \i struct-tag\i0 , \b union\b0 \i union-tag\i0 or \b enum\b0 \i enum-tag\i0 . The selected stack frame\'27s lexical context is used to look up the name.\
\fs48 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \f1 \b0 \fs28 \b set\b0 Perform an assignment \i var\i0 \b =\b0 \i exp\i0 . You must type the \b =\b0 . \i var\i0 may be a debugger convenience variable (a name starting with \b $\b0 ), a register (one of a few standard names starting with \b $\b0 ), or an actual variable in the program being debugged. \i exp\i0 is any expression. Use \b set variable\b0 for variables with names identical to \b set\b0 subcommands.\
\fs20 \
\fs28 With a subcommand listed below, the \b set\b0 command modifies parts of the GDB environment (you can see these environment settings with \b show\b0 and its subcommands). In general, use \b on\b0 (or no argument) to enable a feature, and \b off\b0 to disable it.\
\fs20 \
\fs28 \b set args\b0 \i arg ...\
\fi0 \i0 Set arguments to give the program being debugged when it is started. Follow this command with any number of arguments to be passed to the program.\
\fs20 \
\fs28 \fi-1512 \b set autoload-breakpoints\b0 \i on/off\
\fi0 \i0 Set automatic resetting of breakpoints in dynamic code.\
\fs20 \
\fs28 \fi-1512 \b set autoload-symbols\b0 \i on/off\
\fi0 \i0 Set automatic loading of symbols of dynamic code.\
\fs20 \
\fs28 \fi-1512 \b set catch-user-commands-errors\b0 \i on/off\
\fi0 \i0 Set whether to ignore errors in user commands.\
\fs20 \
\fs28 \fi-1512 \b set complaints\b0 \i num\
\fi0 \i0 Set the maximum number of complaints about incorrect symbols.\
\fs20 \
\fs28 \fi-1512 \b set confirm\b0 \i on/off\
\fi0 \i0 Set whether to confirm potentially dangerous operations.\
\fs20 \
\fs28 \fi-1512 \b set editing\b0 \i on/off\i0 \
\fi0 Set command-line editing.\
\fs20 \
\fs28 \fi-1512 \b set environment\b0 \i var value\
\fi0 \i0 Set environment variable and value to give the program. Arguments are \i var\i0 \i value\i0 where \i var\i0 is the variable name and \i value\i0 is the value. Values of environment variables are uninterpreted strings. This command does not affect the program until the next \b run\b0 command.\
\fs20 \
\fs28 \fi-1512 \b set history expansion\b0 \i on/off\i0 \
\fi0 Set history expansion on command input.\
\fs20 \
\fs28 \fi-1512 \b set history filename\b0 \i file\
\fi0 \i0 Set the filename in which to record the command history (the list of previous commands of which a record is kept).\
\fs20 \
\fs28 \fi-1512 \b set history save\b0 \i on/off\i0 \
\fi0 Set whether the history record is saved when you exit \b gdb\b0 .\
\fs20 \
\fs28 \fi-1512 \b set history size\b0 \i size\
\fi0 \i0 Set the size of the command history (the number of previous commands to keep a record of).\
\fs20 \
\fs28 \fi-1512 \b set lazy-read\b0 \i on/off\
\fi0 \i0 Set whether inferior\'27s memory is read lazily.\
\fs20 \
\fs28 \fi-1512 \b set print address\b0 \i on/off\
\fi0 \i0 Set printing of addresses.\
\fs20 \
\fs28 \fi-1512 \b set print array\b0 \i on/off\
\fi0 \i0 Set pretty printing of arrays.\
\fs20 \
\fs28 \fi-1512 \b set print asm-demangle\b0 \i on/off\
\fi0 \i0 Set demangling of C++ names in disassembly listings.\
\fs20 \
\fs28 \fi-1512 \b set print demangle\b0 \i on/off\
\fi0 \i0 Set demangling of encoded C++ names when displaying symbols.\
\fs20 \
\fs28 \fi-1512 \b set print elements\b0 \i size\
\fi0 \i0 Set limit on string chars or array elements to print. The value \b 0\b0 causes there to be no limit.\
\fs20 \
\fs28 \fi-1512 \b set print object\b0 \i on/off\
\fi0 \i0 Set printing of object\'27s derived type based on vtable info.\
\fs20 \
\fs28 \fi-1512 \b set print sevenbit-strings\b0 \i on/off\
\fi0 \i0 Set printing of 8-bit characters in strings as \b \\\b0 \i nnn\i0 .\
\fs20 \
\fs28 \fi-1512 \b set print vtbl\b0 \i on/off\
\fi0 \i0 Set printing of C++ virtual function tables.\
\fs20 \
\fs28 \fi-1512 \b set print union\b0 \i on/off\
\fi0 \i0 Set printing of unions interior to structures.\
\fs20 \
\fs28 \fi-1512 \b set print pretty\b0 \i on/off\
\fi0 \i0 Set pretty printing of structures.\
\fs20 \
\fs28 \fi-1512 \b set prompt\b0 \i string\
\fi0 \i0 Set GDB\'27s prompt. The argument is an unquoted string.\
\fs20 \
\fs28 \fi-1512 \b set radix\b0 \i on/off\
\fi0 \i0 Set the default input and output number radix.\
\fs20 \
\fs28 \fi-1512 \b set unload-symbols\b0 \i on/off\
\fi0 \i0 Set whether symbols from dynamically loaded code are forgotten for future loads.\
\fs20 \
\fs28 \fi-1512 \b set verbose\b0 \i on/off\i0 \
\fi0 Set whether verbose printing of informational messages is enabled or disabled.\
\fs20 \
\fs28 \fi-1512 \b set view-host\b0 \i host\
\fi0 \i0 Set the host to connect to when viewing.\
\fs20 \
\fs28 \fi-1512 \b set view-program\b0 \i name\
\fi0 \i0 Set the name of the program to connect to when viewing.\
\fi0 \i0 Describe where the specified variable is stored.\
\fs20 \
\fs28 \fi-1512 \b info args\b0 Provide information about the argument variables of the current stack frame.\
\fs20 \
\fs28 \b info breakpoints\b0 [ \i num\i0 ]\
\fi0 Provide information about the status of all breakpoints, or of breakpoint number \i num\i0 . The second column displays \b y\b0 for enabled breakpoints, \b n\b0 for disabled, \b o\b0 for enabled once (disable when hit), or \b d\b0 for enabled but delete when hit. The address and the file/line number are also displayed.\
\fs20 \
\fs28 \fi-1512 The convenience variable \b $_\b0 and the default examine address for \b x\b0 are set to the address of the last breakpoint listed. The convenience variable \b $bpnum\b0 contains the number of the last breakpoint set.\
\fs20 \
\fs28 \b info catch\
\fi0 \b0 Provide information about the exceptions that can be caught in the current stack frame.\
\fs20 \
\fs28 \fi-1512 \b info classes\
\fi0 \b0 Show all Objective C classes.\
\fs20 \
\fs28 \fi-1512 \b info copying\
\fi0 \b0 Show conditions for redistributing copies of GDB.\
\fs20 \
\fs28 \fi-1512 \b info display\
\fi0 \b0 Show expressions to display when program stops, with code numbers.\
\fs20 \
\fs28 \fi-1512 \b info files\b0 Show the names of targets and files being debugged. Shows the entire stack of targets currently in use (including the exec-file, core-file, and process, if any), as well as the symbol file name.\
\fs20 \
\fs28 \b info float\b0 Show the status of the floating point unit.\
\fs20 \
\fs28 \b info frame\b0 [ \i addr\i0 ]\
\fi0 Provide information about the selected stack frame, or the frame at \i addr\i0 .\
\fs20 \
\fs28 \fi-1512 \b info functions\b0 [ \i regexp\i0 ]\
\fi0 Show all function names, or those matching \i regexp\i0 .\
\fs20 \
\fs28 \fi-1512 \b info line\b0 [ \i line_spec\i0 ]\
\fi0 Core addresses of the code for a source line. \i line_spec\i0 can be specified as\
\fs20 \
\fs28 \fi-1512 \i linenum\i0 , to list around that line in current file,\
\fi0 \i file\b \i0 :\b0 \i linenum\i0 , to list around that line in that file,\
\fi0 \i function\i0 , to list around beginning of that function, or\
\fi0 \i file\b \i0 :\b0 \i function\i0 , to distinguish among like-named static functions.\
\fi0 \
\fi0 The default is to describe the last source line that was listed.\
\fs20 \
\fs28 \fi-1512 This sets the default address for \b x\b0 to the line\'27s first instruction so that \b x/i\b0 suffices to start examining the machine code. The address is also stored as the value of \b $_\b0 .\
\fs20 \
\fs28 \b info locals\
\fi0 \b0 Provide information about the local variables of the current stack frame.\
\fs20 \
\fs28 \fi-1512 \b info program\
\fi0 \b0 Show the execution status of the program.\
\fs20 \
\fs28 \fi-1512 \b info registers\b0 [ \i register_name\i0 ]\
\fi0 Show a list of registers and their contents for the selected stack frame. A register name as argument means describe only that register.\
\fs20 \
\fs28 \fi-1512 \b info selectors\
\fi0 \b0 Show all Objective C selectors.\
\fs20 \
\fs28 \fi-1512 \b info set\b0 Show all GDB settings.\
\fs20 \
\fs28 \b info signals\b0 [ \i sig_num\i0 ]\
\fi0 Show what GDB does when the program gets various signals. Specify a signal number to print information about that signal only.\
\fs20 \
\fs28 \fi-1512 \b info sources\
\fi0 \b0 Show the names of source files in the program.\
\fs20 \
\fs28 \fi-1512 \b info source\
\fi0 \b0 Provide information about the current source file.\
\fs20 \
\fs28 \fi-1512 \b info stack\b0 [ \i count\i0 ]\
\fi0 Provide a backtrace of the stack, or of the innermost \i count\i0 frames.\
\fi0 Show all type names, or those matching \i regexp\i0 .\
\fs20 \
\fs28 \fi-1512 \b info user\b0 [ \i command\i0 ]\
\fi0 Show the definition of a user-defined command. With no argument, show the definitions of all user-defined commands.\
\fs20 \
\fs28 \fi-1512 \b info variables\b0 [ \i regexp\i0 ]\
\fi0 Show all global and static variable names, or those matching \i regexp\i0 .\
\fs20 \
\fs28 \fi-1512 \b info warranty\
\fi0 \b0 Show information pertaining to warranty.\
\fs20 \
\fs28 \fi-1512 \b info watchpoints\b0 [ \i num\i0 ]\
\fi0 Provide information about the status of all watchpoints, or of watchpoint number \i num\i0 . The second column displays \b y\b0 for enabled watchpoints or \b n\b0 for disabled ones.\
\fs20 \
\fs28 \fi-1512 \b show autoload-breakpoints\
\fi0 \b0 Show automatic reseting of breakpoints in dynamic code.\
\fs20 \
\fs28 \fi-1512 \b show autoload-symbols\
\fi0 \b0 Show automatic loading of symbols of dynamic code.\
\fs20 \
\fs28 \fi-1512 \b show args\b0 Show arguments to give program being debugged when it is started.\
\fs20 \
\fs28 \b show catch-user-commands-errors\
\fi0 \b0 Show whether to ignore errors in user commands.\
\fi0 \b0 Show the maximum number of complaints about incorrect symbols.\
\fs20 \
\fs28 \fi-1512 \b show confirm\
\fi0 \b0 Show whether to confirm potentially dangerous operations.\
\fs20 \
\fs28 \fi-1512 \b show convenience\
\fi0 \b0 Show the debugger convenience variables. These variables are created when you assign them values; thus, p\b rint $foo=1\b0 gives \b $foo\b0 the value 1. Values may be of any type.\
\fs20 \
\fs28 \fi-1512 A few convenience variables are given values automatically: \b $_\b0 holds the last address examined with \b x\b0 or \b info lines\b0 , and \b $__\b0 holds the contents of the last address examined with \b x\b0 .\
\fs20 \
\fs28 \b show directories\
\fi0 \b0 Current search path for finding source files. \b $cwd\b0 in the path means the current working directory. \b $cdir\b0 in the path means the compilation directory of the source file.\
\fs20 \
\fs28 \fi-1512 \b show editing\
\fi0 \b0 Show command-line editing.\
\fs20 \
\fs28 \fi-1512 \b show environment\b0 [ \i var\i0 ]\
\fi0 Show the environment to give the program, or one variable\'27s value. With an argument \i var\i0 , prints the value of environment variable \i var\i0 to give the program being debugged. With no arguments, prints the entire environment to be given to the program.\
\fs20 \
\fs28 \fi-1512 \b show history expansion\
\fi0 \b0 Show history expansion on command input.\
\fs20 \
\fs28 \fi-1512 \b show history filename\
\fi0 \b0 Show the filename in which to record the command history (the list of previous commands of which a record is kept).\
\fs20 \
\fs28 \fi-1512 \b show history save\
\fi0 \b0 Show saving of the history record on exit.\
\fs20 \
\fs28 \fi-1512 \b show history size\
\fi0 \b0 Show the size of the command history (that is, the number of previous commands to keep a record of).\
\fs20 \
\fs28 \fi-1512 \b show lazy-read\
\fi0 \b0 Show if inferior\'27s memory is read lazily.\
\fs20 \
\fs28 \fi-1512 \b show paths\
\fi0 \b0 Show the current search path for finding object files. \b $cwd\b0 in the path means the current working directory. This path is like the \b $PATH\b0 shell variable; that is, a list of directories separated by colons. These directories are searched to find fully linked executable files and separately compiled object files as needed.\
\fs20 \
\fs28 \fi-1512 \b show print address\
\fi0 \b0 Show printing of addresses.\
\fs20 \
\fs28 \fi-1512 \b show print array\
\fi0 \b0 Show prettyprinting of arrays.\
\fs20 \
\fs28 \fi-1512 \b show print asm-demangle\
\fi0 \b0 Show demangling of C++ names in disassembly listings.\
\fs20 \
\fs28 \fi-1512 \b show print demangle\
\fi0 \b0 Show demangling of encoded C++ names when displaying symbols.\
\fs20 \
\fs28 \fi-1512 \b show print elements\
\fi0 \b0 Show limit on string chars or array elements to print.\
\fs20 \
\fs28 \fi-1512 \b show print object\
\fi0 \b0 Show printing of object\'27s derived type based on vtable info.\
\fs20 \
\fs28 \fi-1512 \b show print pretty\
\fi0 \b0 Show pretty printing of structures.\
\fs20 \
\fs28 \fi-1512 \b show print sevenbit-strings\
\fi0 \b0 Show printing of 8-bit characters in strings as \b \\\b0 \i nnn\i0 .\
\fs20 \
\fs28 \fi-1512 \b show print union\
\fi0 \b0 Show printing of unions interior to structures.\
\fs20 \
\fs28 \fi-1512 \b show print vtbl\
\fi0 \b0 Show printing of C++ virtual function tables.\
\fs20 \
\fs28 \fi-1512 \b show prompt\
\fi0 \b0 Show GDB\'27s prompt.\
\fs20 \
\fs28 \fi-1512 \b show radix\
\fi0 \b0 Show the default input and output number radix.\
\fs20 \
\fs28 \fi-1512 \b show unload-symbols\
\fi0 \b0 Show whether symbols from dynamically loaded code are forgotten for future loads.\
\fs20 \
\fs28 \fi-1512 \b show values\b0 [ \i idx\i0 ]\
\fi0 Elements of value history around item number \i idx\i0 (or last ten).\
\fs20 \
\fs28 \fi-1512 \b show verbose\
\fi0 \b0 Show whether verbosity is on or off.\
\fs20 \
\fs28 \fi-1512 \b show version\
\fi0 \b0 Report what version of GDB this is.\
\fs20 \
\fs28 \fi-1512 \b show view-host\
\fi0 \b0 Show host to connect to when viewing.\
\fs20 \
\fs28 \fi-1512 \b show view-program\
\fi0 \b0 Show name of program to connect to when viewing.\
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 This section describes three commands that are useful when debugging PostScript source files.\
\fs20 \
\fs28 These commands aren\'27t built-in commands; rather, the NEXTSTEP environment defines them in a system \b .gdbinit\b0 file located in the directory \b /usr/lib\b0 . This file is read when you start running GDB (the contents of this file are shown later in this chapter).\
\fi0 \b0 The \b showps\b0 and \b shownops\b0 commands turn on and off (respectively) the display of PostScript code being sent from your application to the Window Server. Your application must be running before you can issue either of these commands.\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \b flush\b0 The \b flush\b0 command sends pending PostScript code to the Window Server. This command lets you flush the application\'27s output buffer, causing any PostScript code waiting there to be interpreted immediately. Your application must be running before you can issue this command.\
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 This section provides information about some commands and command options that are useful for debugging Objective C code.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 The following commands have been extended to accept Objective C method names as line specifications:\
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 For example, to set a breakpoint at the \b create\b0 instance method of class Fruit in the program currently being debugged, enter:\
\fs28 If your program\'27s source files contain more than one \b create\b0 method, you\'27ll be presented with a numbered list of classes that implement that method. Indicate your choice by number, or type 0 to exit if none apply. To narrow the scope of GDB\'27s search, you can use a preceding plus or minus sign to specify whether you\'27re referring to a class or an instance method. For example, to list the ten program lines around the initialize class method, enter\
\fs28 You must specify the complete method name, including any colons. For example, to clear a breakpoint established at the \b orderWindow:relativeTo:\b0 method of the Window class, enter:\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 This section describes commands and options that are useful in debugging Objective C code. Some of these are new commands that have been implemented in NEXTSTEP, and some are previously existing GDB commands that have been extended in NEXTSTEP.\
\fi0 Display all Objective C classes in your application, or those matching the regular expression \i regexp\i0 .\
\fs20 \
\fs28 \fi-1512 \b info selectors\b0 [\i regexp\i0 ] \
\fi0 Display all Objective C selector names (or those matching the regular expression \i regexp\i0 ), and also each selector\'27s unique number.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 If you don\'27t limit the command\'27s scope by entering a regular expression, the resulting listing can be quite long. To terminate a listing at any point and return to the GDB prompt, type Control-C.\
\fs20 \
\fs28 Two standard \b info\b0 command options have been extended. The \b info types\b0 command recognizes and lists the Objective C \b id\b0 type. The \b info line\b0 command recognizes Objective C method names as line specifications.\
\fs36 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 The \b print\b0 command has been extended to allow the evaluation of Objective C objects and message expressions. Consider, for example, this program excerpt:\
\fs28 This structure contains the instance variables defined above for objects of the Fruit class. It also contains a pointer, called \b isa\b0 , that points to its class object. To see the identity of this class, enter:\
\fs28 The instance variable \b name\b0 verifies that this is an instance of the Fruit class.\
\fs20 \
\fs28 You can also evaluate a message expression with the \b print\b0 command. As a by-product of the evaluation, the message is sent to the receiving object. For example, the following command sets the color of the Fruit object to red:\
\fs36 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 The \b set\b0 command can be used to evaluate and send a message expression. For example, the following command sets the color of the Fruit object to red:\
\fs36 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 The \b step\b0 command has been extended to let you step through the execution of an Objective C message. By repeatedly executing the \b step\b0 command, you can watch the chain of events that make up the execution of a message.\
\fs20 \
\fs28 If you step into a message and don\'27t want to follow the details of its execution, enter:\
\fs28 This command completes the execution of the message and stops the program at the next statement. To avoid stepping into the message in the first place, use the \b next\b0 command rather than \b step\b0 . The \b next\b0 command instructs GDB to execute the current command and stop only when control returns to the current stack frame.\
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 The following commands have been provided in the NEXTSTEP version of GDB to support the debugging of Mach threads.\
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 NEXTSTEP GDB has been extended to allow debugging of NEXTSTEP core files, which are in the Mach-O file format. Core files are generated in the \b /cores\b0 directory, if it exists; otherwise, they\'27re generated in the current working directory.\
\fs20 \
\fs28 The \b info files\b0 command lists information about the contents of the core file. This tells you what segments of address space exist in the core file, how many threads exist in the core image, and what the program counter is for each thread. Thread 0 is selected by default, so if you do a \b bt\b0 it will apply to thread 0. The \b thread-list\b0 and \b thread-select\b0 commands, documented in the section \'aaDebugging Mach Threads\'ba above, work with core files. All the normal debugger commands can also be used while debugging the core image.\
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 There are several ways to alter the execution of your program with GDB commands.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 To alter the value of a variable, evaluate an assignment expression. For example:\
\fs28 would store the value 4 into the variable \b x\b0 , and then print the value of the assignment expression (which is 4).\
\fs20 \
\fs28 If you aren\'27t interested in seeing the value of the assignment, use the \b set\b0 command instead of the \b print\b0 command. \b set\b0 is the same as \b print\b0 except that the expression\'27s value isn\'27t printed and isn\'27t put in the value history. The expression is evaluated only for side effects.\
\fs20 \
\fs28 GDB allows more implicit conversions in assignments than C does; you can freely store an integer value into a pointer variable or vice versa, and any structure can be converted to any other structure that\'27s the same length or shorter.\
\fs20 \
\fs28 All the other C assignment operators such as \b +=\b0 and \b ++\b0 are supported as well.\
\fs20 \
\fs28 To store into arbitrary places in memory, use the \b \{\b0 ...\b \}\b0 construct to generate a value of specified type at a specified address. For example:\
\fi0 Resume execution at line number \i linenum\i0 . Execution may stop immediately if there\'27s a breakpoint there.\
\fi0 \
\fi0 The \b jump\b0 command doesn\'27t change the current stack frame, or the stack pointer, or the contents of any memory location or any register other than the program counter. If \i linenum\i0 is in a different function from the one currently executing, the results may be wild if the two functions expect different patterns of arguments or of local variables. For this reason, the \b jump\b0 command requests confirmation if the specified line isn\'27t in the function currently executing.\
\fs20 \
\fs28 \fi-1512 \b jump *\b0 \i address\i0 \
\fi0 Resume execution at the instruction at address \i address\i0 .\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 A somewhat similar effect can be obtained by storing a new value into the register \b $pc\b0 . For example:\
\fs28 specifies the address at which execution will resume, but doesn\'27t resume execution. That doesn\'27t happen until you use the \b cont\b0 command or a stepping command.\
\fi0 You can make any function call return immediately by using the \b return\b0 command.\
\fi0 \
\fi0 First select the stack frame that you want to return from (see the section \'aaSelecting a Frame\'ba). Then type the \b return\b0 command. If you want to specify the value to be returned, give that as an argument.\
\fi0 \
\fi0 The selected stack frame (and any other frames inside it) is popped, leaving its caller as the innermost remaining frame. That frame becomes selected. The specified value is stored in the registers used for returning values of functions.\
\fi0 \
\fi0 The \b return\b0 command doesn\'27t resume execution; it leaves the program stopped in the state that would exist if the function had just returned. Contrast this with the \b finish\b0 command, which resumes execution until the selected stack frame returns naturally.\
\fs52 Defining and Executing Sequences of Commands\
\fs28 \
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 GDB provides two ways to store sequences of commands for execution as a unit: user-defined commands and command files.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 A \'aauser-defined command\'ba is a sequence of GDB commands to which you assign a new name as a command. This is done with the \b define\b0 command.\
\fi0 Define a command named \i commandname\i0 . If there\'27s already a command by that name, you\'27re asked to confirm that you want to redefine it.\
\fi0 \
\fi0 The definition of the command is made up of other GDB command lines, which are given following the \b define\b0 command. The end of the command definition is marked by a line containing just the command \b end\b0 . For example:\
\fi0 Create documentation for the user-defined command \i commandname\i0 . The command \i commandname\i0 must already be defined. This command reads lines of documentation just as \b define\b0 reads the lines of the command definition. After the \b document\b0 command is finished, \b help\b0 on command \i commandname\i0 will print the documentation you have specified.\
\fi0 \
\fi0 You may use the \b document\b0 command again to change the documentation of a command. Redefining the command with \b define\b0 doesn\'27t change the documentation, so be sure to keep the documentation up to date.\
\fs20 \
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 User-defined commands don\'27t take arguments. When they\'27re executed, the commands of the definition aren\'27t printed. An error in any command stops execution of the user-defined command.\
\fs20 \
\fs28 Commands that would ask for confirmation if used interactively proceed without asking when used inside a user-defined command. Many GDB commands that normally print messages to say what they\'27re doing omit the messages when used in a user-defined command.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 A command file for GDB is a file of lines that are GDB commands. Comments (lines starting with \b #\b0 ) may also be included. An empty line in a command file does nothing; it doesn\'27t cause the last command to be repeated, as it would from the terminal.\
\fs20 \
\fs28 When GDB starts, it automatically executes its \'aainit files\'ba (command files named \b .gdbinit\b0 ). GDB first reads the init file (if any) in your home directory and then the init file (if any) in the current working directory. (The init files aren\'27t executed if the \b -nx\b0 option is given.) You can also request the execution of a command file with the \b source\b0 command:\
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 The lines in a command file are executed sequentially. They aren\'27t printed as they\'27re executed. An error in any command terminates execution of the command file.\
\fs20 \
\fs28 Commands that would ask for confirmation if used interactively proceed without asking when used in a command file. Many GDB commands that normally print messages to say what they\'27re doing omit the messages when used in a command file.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 During the execution of a command file or a user-defined command, the only output that appears is what\'27s explicitly printed by the commands of the definition. This section describes three additional commands useful for generating exactly the output you want.\
\fs20 \
\fs28 \pard \s25 \li3628 \fi-1512 \ri1008 \ql \tx3628 \b echo\b0 \i text\i0 Print \i text\i0 . Nonprinting characters can be included in \i text\i0 using C escape sequences, such as \b \\n\b0 to print a newline. No newline will be printed unless you specify one.\
\fi0 \
\fi0 A backslash at the end of \i text\i0 is ignored. It\'27s useful for producing a string ending in spaces, since trailing spaces are trimmed from all arguments. A backslash at the beginning preserves leading spaces in the same way, because the escape sequence backslash-space stands for a space. Thus, to print \'aa variable foo = \'ba, do\
\fi0 Print the values of the arguments, under the control of \i format-string\i0 . This command is identical in its operation to its C library equivalent (see the UNIX manual page for \b printf()\b0 for format codes).\
\fs52 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 Permission is granted to make and distribute verbatim copies of this chapter provided its copyright notice and this permission notice are preserved on all copies.\
\fs20 \
\fs28 Permission is granted to copy and distribute modified versions of this chapter under the conditions for verbatim copying, provided also that the section entitled \'aaGDB General Public License\'ba (below) is included exactly as in the original, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.\
\fs20 \
\fs28 Permission is granted to copy and distribute translations of this chapter into another language, under the above conditions for modified versions, except that the section entitled \'aaGDB General Public License\'ba may be included in a translation approved by the author instead of in the original English.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 GNU software is \i free\i0 ; this means that everyone is free to use it and free to redistribute it on a free basis. GNU software is not in the public domain; it is copyrighted and there are restrictions on its distribution, but these restrictions are designed to permit everything that a good cooperating citizen would want to do. What is not allowed is to try to prevent others from further sharing any version of GNU software that they might get from you. The precise conditions are found in the GNU General Public License that appears following this section.\
\fs20 \
\fs28 You may obtain a complete machine-readable copy of any NEXTSTEP-modified source code for Free Software Foundation software under the terms of Free Software foundation\'27s general public licenses, without charge except for the cost of media, shipping and handling, upon written request to Technical Services at NeXT Computer, Inc.\
\fs20 \
\fs28 When making a request, please specify which GNU software programs you\'27re interested in receiving. GNU programs released by NeXT currently include:\
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 If you want an unmodified, verbatim copy of any GNU software (including GNU software that\'27s not part of the NEXTSTEP software release), you can order it from the Free Software Foundation. Though GNU software itself is free, the distribution service is not. For further information, write to:\
\fs28 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 Income that Free Software Foundation derives from distribution fees goes to support the Foundation\'27s purpose: the development of more free software to distribute.\
\fs48 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 The license agreements of most software companies keep you at the mercy of those companies. By contrast, our general public license is intended to give everyone the right to share GDB. To make sure that you get the rights we want you to have, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. Hence this license agreement.\
\fs20 \
\fs28 Specifically, we want to make sure that you have the right to give away copies of GDB, that you receive source code or else can get it if you want it, that you can change GDB or use pieces of it in new free programs, and that you know you can do these things.\
\fs20 \
\fs28 To make sure that everyone has such rights, we have to forbid you to deprive anyone else of these rights. For example, if you distribute copies of GDB, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights.\
\fs20 \
\fs28 Also, for our own protection, we must make certain that everyone finds out that there is no warranty for GDB. If GDB is modified by someone else and passed on, we want its recipients to know that what they have is not what we distributed, so that any problems introduced by others will not reflect on our reputation.\
\fs20 \
\fs28 Therefore we (Richard Stallman and the Free Software Foundation, Inc.) make the following terms which say what you must do to be allowed to distribute or change GDB.\
\fs36 \pard \s21 \li2494 \fi-378 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 \f0 \fs28 1. \fs28 \f1 You may copy and distribute verbatim copies of GDB source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy a valid copyright notice \'aaCopyright (c) 1988 Free Software Foundation, Inc.\'ba (or with whatever year is appropriate); keep intact the notices on all files that refer to this License Agreement and to the absence of any warranty; and give any other recipients of the GDB program a copy of this License Agreement along with the program. You may charge a distribution fee for the physical act of transferring a copy.\
\fs20 \
\fs28 \s23 \f0 \fs28 2. \fs28 \f1 You may modify your copy or copies of GDB or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following:\
\fs20 \
\fs28 \pard \s8 \li2872 \fi-378 \ri1008 \ql \tx2872 \tx3250 \tx3628 \'b7 cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and\
\fs20 \
\fs28 \'b7 cause the whole of any work that you distribute or publish, that in whole or in part contains or is a derivative of GDB or any part thereof, to be licensed at no charge to all third parties on terms identical to those contained in this License Agreement (except that you may choose to grant more extensive warranty protection to some or all third parties, at your option).\
\fs20 \
\fs28 \'b7 You may charge a distribution fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.\
\fs20 \
\fs28 \pard \s6 \li2494 \fi0 \ri1008 \ql \tx2872 \tx3250 \tx3642 Mere aggregation of another unrelated program with this program (or its derivative) on a volume of a storage or distribution medium does not bring the other program under the scope of these terms.\
\fs20 \
\fs28 \pard \s24 \li2494 \fi-378 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f0 \fs28 3. \fs28 \f1 You may copy and distribute GDB (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following:\
\fs28 \'b7 accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or,\
\fs20 \
\fs28 \'b7 accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal shipping charge) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or,\
\fs20 \
\fs28 \'b7 accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.)\
\fs20 \
\fs28 \pard \s6 \li2494 \fi0 \ri1008 \ql \tx2872 \tx3250 \tx3642 For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs.\
\fs20 \
\fs28 \pard \s23 \li2494 \fi-378 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f0 \fs28 4. \fs28 \f1 You may not copy, sublicense, distribute or transfer GDB except as expressly provided under this License Agreement. Any attempt otherwise to copy, sublicense, distribute or transfer GDB is void and your rights to use the program under this License agreement shall be automatically terminated. However, parties who have received computer software programs from you with this License Agreement will not have their licenses terminated so long as such parties remain in full compliance.\
\fs20 \
\fs28 \f0 \fs28 5. \fs28 \f1 If you wish to incorporate parts of GDB into other free programs whose distribution conditions are different, write to the Free Software Foundation at 675 Mass. Ave., Cambridge, MA 02139. We have not yet worked out a simple rule that can be stated here, but we will often permit this. We will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software.\
\fs20 \
\fs28 \s4 \li2116 \fi0 Your comments and suggestions about our licensing policies and our software are welcome! Please contact the Free Software Foundation, Inc., 675 Mass. Ave., Cambridge, MA 02139, or call (617)876-3296.\
\fs36 \pard \s4 \li2116 \fi0 \ri1008 \ql \tx2494 \tx2872 \tx3250 \f1 \b0 \fs28 BECAUSE GDB IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC, RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE GDB \'aaAS IS\'ba WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF GDB IS WITH YOU. SHOULD GDB PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.\
\fs20 \
\fs28 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M. STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY WHO MAY MODIFY AND REDISTRIBUTE GDB AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) GDB, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.\